default.conf 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. upstream backend_servers {
  2. server backend:8080 max_fails=1 fail_timeout=10s;
  3. }
  4. server {
  5. listen 80;
  6. server_name localhost;
  7. #charset koi8-r;
  8. access_log /var/log/nginx/host.access.log main;
  9. gzip on;
  10. gzip_min_length 1k;
  11. gzip_buffers 4 16k;
  12. gzip_comp_level 8;
  13. gzip_types text/plain application/javascript application/x-javascript text/css application/json text/javascript application/x-httpd-php image/jpeg image/gif image/png;
  14. gzip_vary off;
  15. gzip_disable "MSIE [1-6]\.";
  16. location / {
  17. root /usr/share/nginx/html;
  18. try_files $uri $uri/ /index.html;
  19. index start.html index.html;
  20. }
  21. location /api {
  22. proxy_read_timeout 300;
  23. proxy_pass http://backend_servers;
  24. # 代理头信息配置
  25. proxy_set_header Host $host;
  26. proxy_set_header X-Real-IP $remote_addr;
  27. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  28. proxy_set_header X-Forwarded-Proto $scheme;
  29. }
  30. location /ws {
  31. proxy_read_timeout 300;
  32. proxy_pass http://backend_servers;
  33. proxy_http_version 1.1;
  34. proxy_set_header Upgrade $http_upgrade;
  35. proxy_set_header Connection "Upgrade";
  36. # 代理头信息配置
  37. proxy_set_header Host $host;
  38. proxy_set_header X-Real-IP $remote_addr;
  39. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  40. proxy_set_header X-Forwarded-Proto $scheme;
  41. }
  42. # location /api {
  43. # proxy_read_timeout 300;
  44. # proxy_pass http://192.168.3.177:8080;
  45. # }
  46. # location /ws {
  47. # proxy_read_timeout 300;
  48. # proxy_pass http://192.168.3.177:8080/ws;
  49. # }
  50. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  51. # location /api {
  52. # proxy_pass http://api-server:8082;
  53. # }
  54. }