nginx.conf 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. server {
  11. # 监听端口
  12. listen 9048;
  13. # 域名
  14. server_name 127.0.0.1;
  15. # 编码
  16. charset utf-8;
  17. # web上传文件大小限制
  18. client_max_body_size 5000m;
  19. # 开启gzip压缩
  20. gzip on;
  21. # 不压缩临界值,大于1K的才压缩,一般不用改
  22. gzip_min_length 1k;
  23. # 压缩缓冲区
  24. gzip_buffers 16 64K;
  25. # 压缩版本(默认1.1,前端如果是squid2.5请使用1.0)
  26. gzip_http_version 1.1;
  27. # 压缩级别,1-10,数字越大压缩的越好,时间也越长
  28. gzip_comp_level 5;
  29. # 进行压缩的文件类型
  30. gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
  31. # 跟Squid等缓存服务有关,on的话会在Header里增加"Vary: Accept-Encoding"
  32. gzip_vary on;
  33. # IE6对Gzip不怎么友好,不给它Gzip了
  34. gzip_disable "MSIE [1-6]\.";
  35. # 静态文件
  36. location / {
  37. root ../web;
  38. index index.html index.htm;
  39. }
  40. # 动态代理
  41. location /pro-api/ {
  42. proxy_set_header Host $http_host;
  43. proxy_set_header X-Real-IP $remote_addr;
  44. proxy_set_header REMOTE-HOST $remote_addr;
  45. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  46. proxy_pass http://127.0.0.1:9040/api/;
  47. }
  48. # websocket 支持,如不需要请手动注释
  49. location /socket {
  50. proxy_pass http://127.0.0.1:9040; # 后端 WebSocket 服务器的地址
  51. proxy_http_version 1.1;
  52. proxy_set_header Upgrade $http_upgrade;
  53. proxy_set_header Connection "upgrade";
  54. proxy_set_header Host $host;
  55. proxy_cache_bypass $http_upgrade;
  56. proxy_read_timeout 3600s; # 设置为1小时
  57. proxy_send_timeout 3600s; # 设置为1小时
  58. }
  59. error_page 500 502 503 504 /50x.html;
  60. location = /50x.html {
  61. root ../web;
  62. }
  63. }
  64. }