Files
CosScene/admin-web/nginx.conf
T
shiran f2b4beed0a feat(config): 更新环境配置和Nginx设置以支持动态端口配置
- 修改 .env.example 文件中的客户端API基础路径配置
- 将Dockerfile中的nginx.conf复制到模板目录以支持环境变量
- 在nginx配置中使用环境变量替换硬编码端口
- 为API文档路径(/docs、/redoc、/openapi.json)添加代理配置
- 移除硬编码的服务器地址,改用相对路径配置
- 更新docker-compose.yml以传递内部端口环境变量
- 简化nginx反向代理配置,移除冗余的服务器块配置
2026-05-09 18:08:16 +08:00

54 lines
1.5 KiB
Nginx Configuration File

server {
listen ${ADMIN_WEB_INTERNAL_PORT};
server_name _;
root /usr/share/nginx/html;
index index.html;
location /api/ {
proxy_pass http://server:${SERVER_INTERNAL_PORT}/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /uploads/ {
proxy_pass http://server:${SERVER_INTERNAL_PORT}/uploads/;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
location = /docs {
proxy_pass http://server:${SERVER_INTERNAL_PORT}/docs;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = /redoc {
proxy_pass http://server:${SERVER_INTERNAL_PORT}/redoc;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = /openapi.json {
proxy_pass http://server:${SERVER_INTERNAL_PORT}/openapi.json;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
try_files $uri $uri/ /index.html;
}
}