nginx.conf 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. user nginx;
  2. worker_processes auto;
  3. error_log /var/log/nginx/error.log warn;
  4. pid /var/run/nginx.pid;
  5. worker_rlimit_nofile 51200;
  6. events {
  7. use epoll;
  8. worker_connections 51200;
  9. multi_accept on;
  10. }
  11. http {
  12. include mime.types;
  13. default_type application/octet-stream;
  14. server_names_hash_bucket_size 128;
  15. client_header_buffer_size 32k;
  16. large_client_header_buffers 4 32k;
  17. client_max_body_size 1024m;
  18. client_body_buffer_size 10m;
  19. sendfile on;
  20. tcp_nopush on;
  21. keepalive_timeout 120;
  22. server_tokens off;
  23. tcp_nodelay on;
  24. fastcgi_connect_timeout 300;
  25. fastcgi_send_timeout 300;
  26. fastcgi_read_timeout 300;
  27. fastcgi_buffer_size 64k;
  28. fastcgi_buffers 4 64k;
  29. fastcgi_busy_buffers_size 128k;
  30. fastcgi_temp_file_write_size 128k;
  31. fastcgi_intercept_errors on;
  32. #Gzip Compression
  33. gzip on;
  34. gzip_buffers 16 8k;
  35. gzip_comp_level 6;
  36. gzip_http_version 1.1;
  37. gzip_min_length 256;
  38. gzip_proxied any;
  39. gzip_vary on;
  40. gzip_types
  41. text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
  42. text/javascript application/javascript application/x-javascript
  43. text/x-json application/json application/x-web-app-manifest+json
  44. text/css text/plain text/x-component
  45. font/opentype application/x-font-ttf application/vnd.ms-fontobject
  46. image/x-icon;
  47. gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  48. proxy_ignore_client_abort on;
  49. server {
  50. listen 8001; # 监听端口
  51. # server_name -; # 域名可以有多个,用空格隔开
  52. #charset koi8-r;
  53. #access_log logs/host.access.log main;
  54. location / {
  55. root /opt/web;
  56. index index.html index.htm; #目录内的默认打开文件,如果没有匹配到index.html,则搜索index.htm,依次类推
  57. }
  58. #ssl配置省略
  59. location /api {
  60. # rewrite ^.+api/?(.*)$ /$1 break;
  61. proxy_pass http://ferry_backend:8002; #node api server 即需要代理的IP地址
  62. proxy_redirect off;
  63. proxy_set_header Host $host:$server_port;
  64. proxy_set_header X-Real-IP $remote_addr;
  65. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  66. }
  67. # 登陆
  68. location /login {
  69. proxy_pass http://ferry_backend:8002; #node api server 即需要代理的IP地址
  70. proxy_redirect off;
  71. proxy_ignore_client_abort on;
  72. proxy_max_temp_file_size 256m;
  73. proxy_connect_timeout 90;
  74. proxy_send_timeout 90;
  75. proxy_read_timeout 90;
  76. proxy_buffer_size 4k;
  77. proxy_buffers 4 32k;
  78. proxy_busy_buffers_size 32k;
  79. proxy_temp_file_write_size 64k;
  80. proxy_http_version 1.1;
  81. proxy_set_header Connection "";
  82. proxy_set_header Host $host:$server_port;
  83. proxy_set_header X-Real-IP $remote_addr;
  84. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  85. }
  86. # 刷新token
  87. location /refresh_token {
  88. proxy_pass http://ferry_backend:8002; #node api server 即需要代理的IP地址
  89. proxy_set_header Host $host:$server_port;
  90. }
  91. # 接口地址
  92. location /swagger {
  93. proxy_pass http://ferry_backend:8002; #node api server 即需要代理的IP地址
  94. proxy_set_header Host $host:$server_port;
  95. }
  96. # 后端静态文件路径
  97. location /static/uploadfile {
  98. proxy_pass http://ferry_backend:8002; #node api server 即需要代理的IP地址
  99. proxy_set_header Host $host:$server_port;
  100. }
  101. #error_page 404 /404.html; #对错误页面404.html 做了定向配置
  102. # redirect server error pages to the static page /50x.html
  103. #将服务器错误页面重定向到静态页面/50x.html
  104. #
  105. error_page 500 502 503 504 /50x.html;
  106. location = /50x.html {
  107. root html;
  108. }
  109. }
  110. }