nginx.conf 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 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. rewrite ^/(.*)$ https://wine.gzzzyd.com:443/$1 permanent;
  30. }
  31. # another virtual host using mix of IP-, name-, and port-based configuration
  32. # HTTPS server
  33. #
  34. server {
  35. listen 443 ssl;
  36. server_name wine.gzzzyd.com;
  37. root /usr/local/nginx/dist; # 后台访问路径
  38. keepalive_timeout 100; # 长连接 100s
  39. ssl_certificate /usr/local/ssl/nginx/server.pem;
  40. ssl_certificate_key /usr/local/ssl/nginx/server.key;
  41. ssl_session_timeout 5m;
  42. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  43. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  44. ssl_prefer_server_ciphers on;
  45. location / {
  46. index index.html index.htm;
  47. }
  48. # 接口访问地址 域名 + /api
  49. location ^~/api {
  50. proxy_set_header Host $host;
  51. proxy_set_header X-Real-IP $remote_addr;
  52. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  53. proxy_buffering off;
  54. rewrite ^/api/(.*)$ /$1 break;
  55. proxy_pass http://gateway;
  56. }
  57. }
  58. }