64 lines
1.7 KiB
Nginx Configuration File
64 lines
1.7 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
charset utf-8;
|
|
|
|
client_max_body_size 20M;
|
|
|
|
# 前端静态资源
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
try_files $uri $uri/ /index.html;
|
|
index index.html index.htm;
|
|
}
|
|
|
|
# 后端 API 代理
|
|
location /prod-api/ {
|
|
proxy_pass http://backend:8888/;
|
|
proxy_set_header Host $http_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;
|
|
proxy_connect_timeout 600;
|
|
proxy_read_timeout 600;
|
|
proxy_send_timeout 600;
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
}
|
|
|
|
# 开发环境 API 代理
|
|
location /dev-api/ {
|
|
proxy_pass http://backend:8888/;
|
|
proxy_set_header Host $http_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;
|
|
proxy_connect_timeout 600;
|
|
proxy_read_timeout 600;
|
|
proxy_send_timeout 600;
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
}
|
|
|
|
# 文件上传路径代理
|
|
location /profile/ {
|
|
proxy_pass http://backend:8888/profile/;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
|
|
# 错误页面
|
|
error_page 500 502 503 504 /50x.html;
|
|
location = /50x.html {
|
|
root /usr/share/nginx/html;
|
|
}
|
|
|
|
# 禁止访问隐藏文件
|
|
location ~ /\. {
|
|
deny all;
|
|
access_log off;
|
|
log_not_found off;
|
|
}
|
|
}
|