Aucune description

nginx.conf 2.7KB

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