nginx.conf 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #user nobody;
  2. worker_processes 1;
  3. #error_log logs/error.log;
  4. #error_log logs/error.log notice;
  5. #error_log logs/error.log info;
  6. pid /usr/local/nginx/logs/nginx.pid;
  7. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  14. # '$status $body_bytes_sent "$http_referer" '
  15. # '"$http_user_agent" "$http_x_forwarded_for"';
  16. #access_log logs/access.log main;
  17. sendfile on;
  18. #tcp_nopush on;
  19. #keepalive_timeout 0;
  20. keepalive_timeout 65;
  21. #gzip on;
  22. upstream gateway {
  23. # 接口访问地址
  24. server 172.26.218.204:8800;
  25. }
  26. server {
  27. listen 80;
  28. server_name wine.gzzzyd.com;
  29. client_max_body_size 100m;
  30. rewrite ^/(.*)$ https://wine.gzzzyd.com:443/$1 permanent;
  31. }
  32. # another virtual host using mix of IP-, name-, and port-based configuration
  33. # HTTPS server
  34. #
  35. server {
  36. listen 443 ssl;
  37. server_name wine.gzzzyd.com;
  38. root /usr/local/nginx/dist; # 后台访问路径
  39. client_max_body_size 100m;
  40. keepalive_timeout 100; # 长连接 100s
  41. ssl_certificate /usr/local/ssl/nginx/server.pem;
  42. ssl_certificate_key /usr/local/ssl/nginx/server.key;
  43. ssl_session_timeout 5m;
  44. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  45. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  46. ssl_prefer_server_ciphers on;
  47. location / {
  48. index index.html index.htm;
  49. }
  50. # 接口访问地址 域名 + /api
  51. location ^~/api {
  52. proxy_set_header Host $host;
  53. proxy_set_header X-Real-IP $remote_addr;
  54. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  55. proxy_buffering off;
  56. rewrite ^/api/(.*)$ /$1 break;
  57. proxy_pass http://gateway;
  58. }
  59. }
  60. }