nginx.conf 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. user nginx;
  2. worker_processes 1;
  3. error_log /var/log/nginx/error.log warn;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 1024;
  7. }
  8. http {
  9. include /etc/nginx/mime.types;
  10. default_type application/octet-stream;
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14. access_log /var/log/nginx/access.log main;
  15. sendfile on;
  16. keepalive_timeout 65;
  17. server {
  18. listen 80;
  19. server_name localhost;
  20. location / {
  21. root /app;
  22. index index.html;
  23. try_files $uri $uri/ /index.html;
  24. }
  25. location /api/
  26. {
  27. proxy_pass http://midway:7001/;
  28. proxy_set_header Host $host;
  29. proxy_set_header X-Real-IP $remote_addr;
  30. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  31. proxy_set_header REMOTE-HOST $remote_addr;
  32. #缓存相关配置
  33. #proxy_cache cache_one;
  34. #proxy_cache_key $host$request_uri$is_args$args;
  35. #proxy_cache_valid 200 304 301 302 1h;
  36. #持久化连接相关配置
  37. proxy_connect_timeout 3000s;
  38. proxy_read_timeout 86400s;
  39. proxy_send_timeout 3000s;
  40. #proxy_http_version 1.1;
  41. #proxy_set_header Upgrade $http_upgrade;
  42. #proxy_set_header Connection "upgrade";
  43. add_header X-Cache $upstream_cache_status;
  44. #expires 12h;
  45. }
  46. location /adminer/
  47. {
  48. proxy_pass http://adminer:8080/;
  49. proxy_set_header Host $host;
  50. proxy_set_header X-Real-IP $remote_addr;
  51. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  52. proxy_set_header REMOTE-HOST $remote_addr;
  53. #缓存相关配置
  54. #proxy_cache cache_one;
  55. #proxy_cache_key $host$request_uri$is_args$args;
  56. #proxy_cache_valid 200 304 301 302 1h;
  57. #持久化连接相关配置
  58. proxy_connect_timeout 3000s;
  59. proxy_read_timeout 86400s;
  60. proxy_send_timeout 3000s;
  61. #proxy_http_version 1.1;
  62. #proxy_set_header Upgrade $http_upgrade;
  63. #proxy_set_header Connection "upgrade";
  64. add_header X-Cache $upstream_cache_status;
  65. #expires 12h;
  66. }
  67. error_page 500 502 503 504 /50x.html;
  68. location = /50x.html {
  69. root /usr/share/nginx/html;
  70. }
  71. }
  72. }