From 48bede361ceb6f5284f393e45be291b2e2446fcc Mon Sep 17 00:00:00 2001 From: jmal Date: Fri, 27 Jun 2025 17:50:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor(nginx):=20=E4=BC=98=E5=8C=96=20Nginx?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了不必要的注释行- 将重复的 proxy_set_header 配置替换为 include 文件- 更新了文件路径,使用 /etc/nginx/nginx.conf - 修正了 X-Forwarded-Host 的值 --- nginx/nginx.conf.no_office.template | 55 ++++++++++++----------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/nginx/nginx.conf.no_office.template b/nginx/nginx.conf.no_office.template index 927cf60..4d9fac8 100644 --- a/nginx/nginx.conf.no_office.template +++ b/nginx/nginx.conf.no_office.template @@ -1,5 +1,4 @@ -# nginx : /usr/local/Cellar/nginx/nginx-1.17.8/objs/nginx -# nginx.conf : /usr/local/nginx/conf/nginx.conf +# nginx.conf : /etc/nginx/nginx.conf #user nobody; worker_processes auto; # 自动根据 CPU 核心数设置 @@ -73,32 +72,27 @@ http { location = / { proxy_pass http://jmalcloud:8088/articles; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } location /api { - proxy_pass http://jmalcloud:8088; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + proxy_pass http://jmalcloud:8088; + include /etc/nginx/conf/proxy_params.conf; } location /articles/articles { proxy_pass http://jmalcloud:8088/articles; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } location /articles { proxy_pass http://jmalcloud:8088/articles; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } location / { proxy_pass http://jmalcloud:8088/articles/; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } } @@ -118,53 +112,48 @@ http { location = /blog { proxy_pass http://jmalcloud:8088/articles; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } location = /blog/ { proxy_pass http://jmalcloud:8088/articles; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } location /blog/api/ { proxy_pass http://jmalcloud:8088/; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } location /blog/articles { proxy_pass http://jmalcloud:8088/articles/; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } location /blog/ { proxy_pass http://jmalcloud:8088/articles/; - proxy_set_header Host $proxy_host; - proxy_set_header X-real-ip $remote_addr; + include /etc/nginx/conf/proxy_params.conf; } location /api/ { proxy_pass http://jmalcloud:8088/; proxy_set_header X-Forwarded-Host $the_host/file; - include /usr/local/nginx/conf/proxy_params.conf; - include /usr/local/nginx/conf/proxy_params_file.conf; + include /etc/nginx/conf/proxy_params.conf; + include /etc/nginx/conf/proxy_params_file.conf; } location /webDAV/ { proxy_pass http://jmalcloud:8088/webDAV/; proxy_set_header X-Forwarded-Host $the_host/file; - include /usr/local/nginx/conf/proxy_params.conf; - include /usr/local/nginx/conf/proxy_params_file.conf; + include /etc/nginx/conf/proxy_params.conf; + include /etc/nginx/conf/proxy_params_file.conf; } location /file/ { proxy_pass http://jmalcloud:8088/file/; proxy_set_header X-Forwarded-Host $the_host/file; - include /usr/local/nginx/conf/proxy_params.conf; - include /usr/local/nginx/conf/proxy_params_file.conf; + include /etc/nginx/conf/proxy_params.conf; + include /etc/nginx/conf/proxy_params_file.conf; } location /mq { @@ -181,19 +170,19 @@ http { location /drawio/webapp/ { proxy_pass http://localhost:8080/; - proxy_set_header X-Forwarded-Host $the_host//drawio/webapp; - include /usr/local/nginx/conf/proxy_params.conf; + proxy_set_header X-Forwarded-Host $the_host/drawio/webapp; + include /etc/nginx/conf/proxy_params.conf; } location /pdf.js/ { proxy_pass http://localhost:8081/; - include /usr/local/nginx/conf/proxy_params.conf; + include /etc/nginx/conf/proxy_params.conf; proxy_set_header X-Forwarded-Host $the_host//pdf.js; } location /excalidraw/app/ { proxy_pass http://localhost:8082/excalidraw/app/; - include /usr/local/nginx/conf/proxy_params.conf; + include /etc/nginx/conf/proxy_params.conf; proxy_set_header X-Forwarded-Host $the_host//excalidraw/app; } }