1
0

nginx.conf 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. user nginx;
  2. worker_processes auto;
  3. error_log /var/log/nginx/error.log warn;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream;
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14. access_log /var/log/nginx/access.log main;
  15. sendfile on;
  16. tcp_nopush on;
  17. tcp_nodelay on;
  18. keepalive_timeout 65;
  19. types_hash_max_size 2048;
  20. client_max_body_size 10M;
  21. # Gzip compression
  22. gzip on;
  23. gzip_vary on;
  24. gzip_min_length 1024;
  25. gzip_proxied any;
  26. gzip_comp_level 6;
  27. gzip_types
  28. text/plain
  29. text/css
  30. text/xml
  31. text/javascript
  32. application/json
  33. application/javascript
  34. application/xml+rss
  35. application/atom+xml
  36. image/svg+xml;
  37. server {
  38. listen 80;
  39. server_name _;
  40. root /usr/share/nginx/html;
  41. index index.html;
  42. # Security headers
  43. add_header X-Frame-Options "SAMEORIGIN" always;
  44. add_header X-Content-Type-Options "nosniff" always;
  45. add_header X-XSS-Protection "1; mode=block" always;
  46. add_header Referrer-Policy "strict-origin-when-cross-origin" always;
  47. # API proxy
  48. location /api/ {
  49. proxy_pass http://waouw_backend:8000/api/;
  50. proxy_set_header Host $host;
  51. proxy_set_header X-Real-IP $remote_addr;
  52. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  53. proxy_set_header X-Forwarded-Proto $scheme;
  54. proxy_connect_timeout 30s;
  55. proxy_send_timeout 30s;
  56. proxy_read_timeout 30s;
  57. }
  58. # Static files with caching
  59. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
  60. expires 1y;
  61. add_header Cache-Control "public, immutable";
  62. try_files $uri =404;
  63. }
  64. # Handle React Router (SPA)
  65. location / {
  66. try_files $uri $uri/ /index.html;
  67. # No cache for HTML files
  68. location ~* \.html$ {
  69. expires -1;
  70. add_header Cache-Control "no-cache, no-store, must-revalidate";
  71. }
  72. }
  73. # Health check endpoint
  74. location /health {
  75. access_log off;
  76. return 200 "healthy\n";
  77. add_header Content-Type text/plain;
  78. }
  79. }
  80. }