|
|
@@ -3,7 +3,7 @@
|
|
|
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
|
|
|
|
|
########### 每个指令必须有分号结束。#################
|
|
|
-worker_processes 1; # 允许生成的进程数,默认为1:
|
|
|
+worker_processes 1; # 允许生成的进程数,默认为1
|
|
|
pid /var/run/nginx.pid; # 指定 Nginx 进程运行文件存放地址
|
|
|
error_log /var/log/nginx/error.log;
|
|
|
|
|
|
@@ -21,53 +21,35 @@ http {
|
|
|
# 访问服务日志
|
|
|
access_log on;
|
|
|
|
|
|
- sendfile on; # 允许sendfile方式传输文件,默认为off,可以在http块、server块、location块
|
|
|
+ sendfile on; # 允许sendfile方式传输文件,默认为off
|
|
|
|
|
|
- keepalive_timeout 75; # 连接超时时间,默认为75秒,可以在http、server、location块
|
|
|
+ keepalive_timeout 75; # 连接超时时间,默认为75秒
|
|
|
|
|
|
- # HTTP server块 - 重定向到HTTPS
|
|
|
+ # 仅保留HTTP server块(删除HTTPS和域名重定向)
|
|
|
server {
|
|
|
- listen 80;
|
|
|
- server_name service.fastapiadmin.com;
|
|
|
- return 301 https://$server_name$request_uri;
|
|
|
- }
|
|
|
-
|
|
|
- # HTTPS server块
|
|
|
- server {
|
|
|
- listen 443 ssl http2;
|
|
|
- server_name service.fastapiadmin.com;
|
|
|
-
|
|
|
- # SSL证书配置
|
|
|
- ssl_certificate /etc/nginx/ssl/service.fastapiadmin.com.pem;
|
|
|
- ssl_certificate_key /etc/nginx/ssl/service.fastapiadmin.com.key;
|
|
|
-
|
|
|
- # SSL优化配置
|
|
|
- ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
- ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384;
|
|
|
- ssl_prefer_server_ciphers on;
|
|
|
- ssl_session_cache shared:SSL:10m;
|
|
|
- ssl_session_timeout 10m;
|
|
|
+ listen 80; # 内网仅用80端口访问
|
|
|
+ server_name _; # 匹配所有IP/无域名场景,替代原域名
|
|
|
|
|
|
- # 官网代理 - 根路径访问官网
|
|
|
+ # 官网代理 - 根路径访问官网(IP+端口直接访问)
|
|
|
location / {
|
|
|
root /usr/share/nginx/html/fastdocs/dist;
|
|
|
index index.html index.htm;
|
|
|
try_files $uri $uri/ /index.html; #解决页面刷新404问题
|
|
|
}
|
|
|
|
|
|
- # 前端代理 - /web访问前端
|
|
|
+ # 前端代理 - /web访问前端(http://192.168.0.247/web)
|
|
|
location /web {
|
|
|
alias /usr/share/nginx/html/frontend/dist;
|
|
|
try_files $uri $uri/ /web/index.html; #解决页面刷新404问题
|
|
|
}
|
|
|
|
|
|
- # 小程序代理 - /app访问小程序
|
|
|
+ # 小程序代理 - /app访问小程序(http://192.168.0.247/app)
|
|
|
location /app {
|
|
|
alias /usr/share/nginx/html/fastapp/dist/build/h5;
|
|
|
try_files $uri $uri/ /app/index.html; #解决页面刷新404问题
|
|
|
}
|
|
|
|
|
|
- # 后端代理
|
|
|
+ # 后端代理 - /api/v1转发到内网后端服务
|
|
|
location /api/v1 {
|
|
|
proxy_set_header Host $host;
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
@@ -77,14 +59,16 @@ http {
|
|
|
proxy_connect_timeout 300s;
|
|
|
proxy_send_timeout 300s;
|
|
|
proxy_read_timeout 300s;
|
|
|
- proxy_pass http://172.18.52.77:8001;
|
|
|
+ # 替换为你的后端服务地址(内网IP+端口,若后端在docker内可填容器名/内网IP)
|
|
|
+ proxy_pass http://192.168.0.247:8001;
|
|
|
|
|
|
- # WebSocket 支持
|
|
|
+ # WebSocket 支持(保留,不影响HTTP)
|
|
|
proxy_http_version 1.1;
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
}
|
|
|
|
|
|
+ # 错误页面配置
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
location = /50x.html {
|
|
|
root /usr/share/nginx/html;
|