nginx.conf 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. worker_processes 1;
  2. error_log /var/log/nginx/error.log warn;
  3. pid /var/run/nginx.pid;
  4. events {
  5. worker_connections 1024;
  6. }
  7. http {
  8. include mime.types;
  9. default_type application/octet-stream;
  10. sendfile on;
  11. keepalive_timeout 65;
  12. # 限制body大小
  13. client_max_body_size 100m;
  14. # 开启静态资源压缩
  15. gzip_static on;
  16. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  17. '$status $body_bytes_sent "$http_referer" '
  18. '"$http_user_agent" "$http_x_forwarded_for"';
  19. access_log /var/log/nginx/access.log main;
  20. upstream server {
  21. ip_hash;
  22. # gateway 地址
  23. server 127.0.0.1:8080;
  24. # server 127.0.0.1:8081;
  25. }
  26. server {
  27. listen 80;
  28. server_name localhost;
  29. # https配置参考 start
  30. #listen 443 ssl;
  31. # 证书直接存放 /docker/nginx/cert/ 目录下即可 更改证书名称即可 无需更改证书路径
  32. #ssl on;
  33. #ssl_certificate /etc/nginx/cert/xxx.local.crt; # /etc/nginx/cert/ 为docker映射路径 不允许更改
  34. #ssl_certificate_key /etc/nginx/cert/xxx.local.key; # /etc/nginx/cert/ 为docker映射路径 不允许更改
  35. #ssl_session_timeout 5m;
  36. #ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  37. #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  38. #ssl_prefer_server_ciphers on;
  39. # https配置参考 end
  40. # 演示环境配置 拦截除 GET POST 之外的所有请求
  41. # if ($request_method !~* GET|POST) {
  42. # rewrite ^/(.*)$ /403;
  43. # }
  44. # location = /403 {
  45. # default_type application/json;
  46. # return 200 '{"msg":"演示模式,不允许操作","code":500}';
  47. # }
  48. # 限制外网访问内网 actuator 相关路径
  49. location ~ ^(/[^/]*)?/actuator.*(/.*)?$ {
  50. return 403;
  51. }
  52. location / {
  53. root /usr/share/nginx/html; # docker映射路径 不允许更改
  54. try_files $uri $uri/ /index.html;
  55. index index.html index.htm;
  56. }
  57. location /prod-api/ {
  58. proxy_set_header Host $http_host;
  59. proxy_set_header X-Real-IP $remote_addr;
  60. proxy_set_header REMOTE-HOST $remote_addr;
  61. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  62. proxy_read_timeout 86400s;
  63. # sse 与 websocket参数
  64. proxy_http_version 1.1;
  65. proxy_set_header Upgrade $http_upgrade;
  66. proxy_set_header Connection "upgrade";
  67. proxy_buffering off;
  68. proxy_cache off;
  69. proxy_pass http://server/;
  70. }
  71. error_page 500 502 503 504 /50x.html;
  72. location = /50x.html {
  73. root html;
  74. }
  75. }
  76. }