nginx.conf 1.5 KB

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