oa_front/nginx.conf

92 lines
2.5 KiB
Nginx Configuration File
Raw Normal View History

2024-02-28 10:51:39 +08:00
user root;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
2024-03-27 16:27:16 +08:00
client_max_body_size 20m;
2024-02-28 10:51:39 +08:00
map $time_iso8601 $logdate {
'~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;
default 'date-not-found';
}
log_format main '$remote_addr [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer"';
root /var/log/nginx;
access_log /var/log/nginx/access-$logdate.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
2024-03-27 16:54:11 +08:00
listen 3001;
2024-03-28 11:20:27 +08:00
server_name 144.123.43.138;
2024-02-28 10:51:39 +08:00
absolute_redirect off; #取消绝对路径的重定向
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location / {
# same docker config
root /usr/share/nginx/html;
index index.html;
# support history mode
try_files $uri $uri/ /index.html;
}
# 后端服务
2024-03-28 11:20:27 +08:00
location /api/ {
2024-03-27 16:54:11 +08:00
proxy_pass http://huaxin-admin-server:8001/api/; # 转发规则
2024-02-28 10:51:39 +08:00
proxy_set_header Host $proxy_host; # 修改转发请求头,让目标应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# websocket服务
2024-03-28 11:20:27 +08:00
location /ws-api/ {
2024-03-27 16:54:11 +08:00
proxy_pass http://huaxin-admin-server:8002/ws-api/;
2024-02-28 10:51:39 +08:00
proxy_read_timeout 300s;
proxy_send_timeout 300s;
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_http_version 1.1;
}
# 文件访问
2024-03-28 13:24:46 +08:00
location /upload/ {
2024-03-27 16:54:11 +08:00
proxy_pass http://huaxin-admin-server:8001/upload/;
2024-02-28 10:51:39 +08:00
proxy_set_header Host $proxy_host; # 修改转发请求头,让目标应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}