refactor(nginx): 优化 Nginx 配置文件

- 移除了不必要的注释行- 将重复的 proxy_set_header 配置替换为 include 文件- 更新了文件路径,使用 /etc/nginx/nginx.conf
- 修正了 X-Forwarded-Host 的值
This commit is contained in:
jmal 2025-06-27 17:50:30 +08:00
parent 7065b9a15f
commit 48bede361c

View File

@ -1,5 +1,4 @@
# nginx : /usr/local/Cellar/nginx/nginx-1.17.8/objs/nginx # nginx.conf : /etc/nginx/nginx.conf
# nginx.conf : /usr/local/nginx/conf/nginx.conf
#user nobody; #user nobody;
worker_processes auto; # 自动根据 CPU 核心数设置 worker_processes auto; # 自动根据 CPU 核心数设置
@ -73,32 +72,27 @@ http {
location = / { location = / {
proxy_pass http://jmalcloud:8088/articles; proxy_pass http://jmalcloud:8088/articles;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location /api { location /api {
proxy_pass http://jmalcloud:8088; proxy_pass http://jmalcloud:8088;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location /articles/articles { location /articles/articles {
proxy_pass http://jmalcloud:8088/articles; proxy_pass http://jmalcloud:8088/articles;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location /articles { location /articles {
proxy_pass http://jmalcloud:8088/articles; proxy_pass http://jmalcloud:8088/articles;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location / { location / {
proxy_pass http://jmalcloud:8088/articles/; proxy_pass http://jmalcloud:8088/articles/;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
} }
@ -118,53 +112,48 @@ http {
location = /blog { location = /blog {
proxy_pass http://jmalcloud:8088/articles; proxy_pass http://jmalcloud:8088/articles;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location = /blog/ { location = /blog/ {
proxy_pass http://jmalcloud:8088/articles; proxy_pass http://jmalcloud:8088/articles;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location /blog/api/ { location /blog/api/ {
proxy_pass http://jmalcloud:8088/; proxy_pass http://jmalcloud:8088/;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location /blog/articles { location /blog/articles {
proxy_pass http://jmalcloud:8088/articles/; proxy_pass http://jmalcloud:8088/articles/;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location /blog/ { location /blog/ {
proxy_pass http://jmalcloud:8088/articles/; proxy_pass http://jmalcloud:8088/articles/;
proxy_set_header Host $proxy_host; include /etc/nginx/conf/proxy_params.conf;
proxy_set_header X-real-ip $remote_addr;
} }
location /api/ { location /api/ {
proxy_pass http://jmalcloud:8088/; proxy_pass http://jmalcloud:8088/;
proxy_set_header X-Forwarded-Host $the_host/file; proxy_set_header X-Forwarded-Host $the_host/file;
include /usr/local/nginx/conf/proxy_params.conf; include /etc/nginx/conf/proxy_params.conf;
include /usr/local/nginx/conf/proxy_params_file.conf; include /etc/nginx/conf/proxy_params_file.conf;
} }
location /webDAV/ { location /webDAV/ {
proxy_pass http://jmalcloud:8088/webDAV/; proxy_pass http://jmalcloud:8088/webDAV/;
proxy_set_header X-Forwarded-Host $the_host/file; proxy_set_header X-Forwarded-Host $the_host/file;
include /usr/local/nginx/conf/proxy_params.conf; include /etc/nginx/conf/proxy_params.conf;
include /usr/local/nginx/conf/proxy_params_file.conf; include /etc/nginx/conf/proxy_params_file.conf;
} }
location /file/ { location /file/ {
proxy_pass http://jmalcloud:8088/file/; proxy_pass http://jmalcloud:8088/file/;
proxy_set_header X-Forwarded-Host $the_host/file; proxy_set_header X-Forwarded-Host $the_host/file;
include /usr/local/nginx/conf/proxy_params.conf; include /etc/nginx/conf/proxy_params.conf;
include /usr/local/nginx/conf/proxy_params_file.conf; include /etc/nginx/conf/proxy_params_file.conf;
} }
location /mq { location /mq {
@ -181,19 +170,19 @@ http {
location /drawio/webapp/ { location /drawio/webapp/ {
proxy_pass http://localhost:8080/; proxy_pass http://localhost:8080/;
proxy_set_header X-Forwarded-Host $the_host//drawio/webapp; proxy_set_header X-Forwarded-Host $the_host/drawio/webapp;
include /usr/local/nginx/conf/proxy_params.conf; include /etc/nginx/conf/proxy_params.conf;
} }
location /pdf.js/ { location /pdf.js/ {
proxy_pass http://localhost:8081/; 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; proxy_set_header X-Forwarded-Host $the_host//pdf.js;
} }
location /excalidraw/app/ { location /excalidraw/app/ {
proxy_pass http://localhost:8082/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; proxy_set_header X-Forwarded-Host $the_host//excalidraw/app;
} }
} }