nginx.conf 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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压缩
  11. gzip on;
  12. # 不压缩临界值,大于1K的才压缩,一般不用改
  13. gzip_min_length 1k;
  14. # 压缩缓冲区
  15. gzip_buffers 16 64K;
  16. # 压缩版本(默认1.1,前端如果是squid2.5请使用1.0)
  17. gzip_http_version 1.1;
  18. # 压缩级别,1-10,数字越大压缩的越好,时间也越长
  19. gzip_comp_level 5;
  20. # 进行压缩的文件类型
  21. gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
  22. # 跟Squid等缓存服务有关,on的话会在Header里增加"Vary: Accept-Encoding"
  23. gzip_vary on;
  24. # IE6对Gzip不怎么友好,不给它Gzip了
  25. gzip_disable "MSIE [1-6]\.";
  26. server {
  27. listen 80;
  28. server_name localhost;
  29. charset utf-8;
  30. location / {
  31. root F:/workspace/Situation-Display/dist;
  32. try_files $uri $uri/ /index.html;
  33. index index.html index.htm;
  34. }
  35. location /api/ {
  36. proxy_set_header Host $http_host;
  37. proxy_set_header X-Real-IP $remote_addr;
  38. proxy_set_header REMOTE-HOST $remote_addr;
  39. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  40. proxy_pass http://127.0.0.1:3000/;
  41. }
  42. error_page 500 502 503 504 /50x.html;
  43. location = /50x.html {
  44. root html;
  45. }
  46. }
  47. }