nginx.conf 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. worker_processes 1;
  2. events {
  3. worker_connections 1024;
  4. }
  5. http {
  6. include mime.types;
  7. default_type application/octet-stream;
  8. sendfile on;
  9. keepalive_timeout 65;
  10. gzip on;
  11. gzip_min_length 1k;
  12. gzip_buffers 16 64K;
  13. gzip_http_version 1.1;
  14. gzip_comp_level 5;
  15. gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
  16. gzip_vary on;
  17. gzip_proxied expired no-cache no-store private auth;
  18. gzip_disable "MSIE [1-6]\.";
  19. server {
  20. listen 443 ssl;
  21. listen 80;
  22. server_name localhost;
  23. charset utf-8;
  24. ssl_certificate /etc/nginx/key/abc.admin.com.pem;
  25. ssl_certificate_key /etc/nginx/key/abc.admin.com.key;
  26. ssl_session_cache shared:SSL:1m;
  27. location / {
  28. root /usr/share/nginx/html;
  29. try_files $uri $uri/ /index.html;
  30. index index.html index.htm;
  31. # 如果缓存了 index.html ,刷新后可能仍会出现更新通知,因此需要禁用 index.html 的缓存。这也是部署 SPA 应用程序的最佳做法。
  32. if ( $uri = '/index.html' ) { # disabled index.html cache
  33. add_header Cache-Control "no-cache, no-store, must-revalidate";
  34. }
  35. }
  36. location /prod-api/hubs {
  37. proxy_pass http://adminNet:5050/hubs; #启用http长连接支持websocket
  38. proxy_http_version 1.1;
  39. proxy_set_header Upgrade $http_upgrade;
  40. proxy_set_header Connection "upgrade";
  41. }
  42. location /prod-api/ {
  43. proxy_set_header Host $http_host;
  44. proxy_set_header X-Real-IP $remote_addr;
  45. proxy_set_header REMOTE-HOST $remote_addr;
  46. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  47. proxy_pass http://adminNet:5050/;
  48. }
  49. error_page 500 502 503 504 /50x.html;
  50. location = /50x.html {
  51. root html;
  52. }
  53. }
  54. }