nginx.conf 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. stream {
  8. upstream nacos-grpc-9848 {
  9. server 172.25.0.18:9848;
  10. }
  11. upstream nacos-grpc-9849 {
  12. server 172.25.0.18:9849;
  13. }
  14. server {
  15. listen 9848;
  16. proxy_connect_timeout 3s;
  17. proxy_timeout 300s;
  18. proxy_pass nacos-grpc-9848;
  19. }
  20. server {
  21. listen 9849;
  22. proxy_connect_timeout 3s;
  23. proxy_timeout 300s;
  24. proxy_pass nacos-grpc-9849;
  25. }
  26. }
  27. http {
  28. include mime.types;
  29. default_type application/octet-stream;
  30. sendfile on;
  31. keepalive_timeout 65;
  32. # 限制body大小
  33. client_max_body_size 100m;
  34. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  35. '$status $body_bytes_sent "$http_referer" '
  36. '"$http_user_agent" "$http_x_forwarded_for"';
  37. access_log /var/log/nginx/access.log main;
  38. upstream gatewaycluster {
  39. ip_hash;
  40. # gateway 地址
  41. server 172.25.0.31:8080;
  42. # server 127.0.0.1:8081;
  43. }
  44. upstream nacoscluster {
  45. ip_hash;
  46. server 172.25.0.18:8848;
  47. }
  48. upstream ruoyimonitor {
  49. ip_hash;
  50. server 172.25.0.51:9100;
  51. server 172.25.0.52:9100;
  52. }
  53. #nacos
  54. server {
  55. listen 8848;
  56. server_name nacos_cluster;
  57. location / {
  58. proxy_pass http://nacoscluster;
  59. }
  60. }
  61. #ruoyi-monitor
  62. server {
  63. listen 9100;
  64. server_name ruoyi_monitor;
  65. location / {
  66. root html;
  67. index index.html index.htm;
  68. proxy_pass http://ruoyimonitor;
  69. }
  70. location ~ .* {
  71. proxy_pass http://ruoyimonitor;
  72. proxy_set_header Host $http_host;
  73. proxy_set_header X-Real-IP $remote_addr;
  74. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  75. }
  76. location = /50x.html {
  77. root html;
  78. }
  79. location /apple-app-site-association {
  80. default_type application/pkcs7-mime;
  81. }
  82. }
  83. #gateway or www
  84. server {
  85. listen 80;
  86. server_name localhost;
  87. # https配置参考 start
  88. #listen 443 ssl;
  89. # 证书直接存放 /docker/nginx/cert/ 目录下即可 更改证书名称即可 无需更改证书路径
  90. #ssl on;
  91. #ssl_certificate /etc/nginx/cert/xxx.local.crt; # /etc/nginx/cert/ 为docker映射路径 不允许更改
  92. #ssl_certificate_key /etc/nginx/cert/xxx.local.key; # /etc/nginx/cert/ 为docker映射路径 不允许更改
  93. #ssl_session_timeout 5m;
  94. #ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  95. #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  96. #ssl_prefer_server_ciphers on;
  97. # https配置参考 end
  98. # 演示环境配置 拦截除 GET POST 之外的所有请求
  99. # if ($request_method !~* GET|POST) {
  100. # rewrite ^/(.*)$ /403;
  101. # }
  102. # location = /403 {
  103. # default_type application/json;
  104. # return 200 '{"msg":"演示模式,不允许操作","code":500}';
  105. # }
  106. # 限制外网访问内网 actuator 相关路径
  107. location ~ ^(/[^/]*)?/actuator(/.*)?$ {
  108. return 403;
  109. }
  110. location / {
  111. root /usr/share/nginx/html;
  112. try_files $uri $uri/ /index.html;
  113. index index.html index.htm;
  114. }
  115. location /prod-api/ {
  116. proxy_set_header Host $http_host;
  117. proxy_set_header X-Real-IP $remote_addr;
  118. proxy_set_header REMOTE-HOST $remote_addr;
  119. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  120. proxy_pass http://gatewaycluster/;
  121. }
  122. location /nacos/ {
  123. proxy_set_header Host $http_host;
  124. proxy_set_header X-Real-IP $remote_addr;
  125. proxy_set_header REMOTE-HOST $remote_addr;
  126. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  127. proxy_pass http://nacoscluster/nacos/;
  128. }
  129. error_page 500 502 503 504 /50x.html;
  130. location = /50x.html {
  131. root html;
  132. }
  133. }
  134. }