73 lines
1.9 KiB
Text
73 lines
1.9 KiB
Text
worker_processes 1;
|
|
user tf tf;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
# 定义 HTTP 块
|
|
http {
|
|
# 定义 server 块
|
|
server {
|
|
listen ${NGINX_PORT};
|
|
|
|
root /app/web;
|
|
index index.html;
|
|
|
|
include /etc/nginx/mime.types;
|
|
|
|
# 定义 WS 的代理规则
|
|
location /ws {
|
|
proxy_pass http://localhost:8080;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
|
|
# 定义 API 的代理规则
|
|
location /api/ {
|
|
proxy_pass http://localhost:8080/;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
|
|
location / {
|
|
try_files $uri $uri.html $uri/ =404;
|
|
}
|
|
|
|
location /_next/static/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
|
}
|
|
|
|
gzip on;
|
|
gzip_disable "msie6";
|
|
gzip_comp_level 6;
|
|
gzip_min_length 256;
|
|
gzip_proxied any;
|
|
gzip_vary on;
|
|
gzip_buffers 16 8k;
|
|
gzip_http_version 1.1;
|
|
gzip_types
|
|
text/plain
|
|
text/css
|
|
text/javascript
|
|
application/javascript
|
|
application/json
|
|
application/x-javascript
|
|
application/xml
|
|
application/xml+rss
|
|
application/vnd.ms-fontobject
|
|
application/x-font-ttf
|
|
font/opentype
|
|
image/svg+xml
|
|
image/x-icon;
|
|
|
|
# 日志配置
|
|
access_log /var/log/nginx/access.log;
|
|
error_log /var/log/nginx/error.log;
|
|
}
|
|
}
|