postcat/nginx.conf

87 lines
2.8 KiB
Nginx Configuration File
Raw Normal View History

2022-11-01 21:41:26 +08:00
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
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 / {
return 301 $scheme://$http_host/zh;
}
location /zh {
alias /usr/share/nginx/html/zh;
index index.html index.htm;
try_files $uri $uri/ /zh/index.html;
}
location /en {
alias /usr/share/nginx/html/en;
index index.html index.htm;
try_files $uri $uri/ /en/index.html;
}
# api测试服务
location /api/unit {
proxy_pass http://eoapi-test-server:4201; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# websocket测试服务
location ~/socket.io/(.*) {
proxy_pass http://eoapi-test-server:4202; # 转发规则
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
}
# 后端服务
location ^~ /api {
proxy_pass http://eoapi-remote-server:3000; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 后端服务兼容旧客户端
2022-11-04 19:31:43 +08:00
location ~ ^/(system|workspace|user|auth|mock|[0-9]+/[0-9]+/api_data|[0-9]+/[0-9]+/group|[0-9]+/[0-9]+/group|[0-9]+/[0-9]+/environment|[0-9]+/[0-9]+/api_test_history|[0-9]+/[0-9]+/mock|[0-9]+/[0-9]+/shared|[0-9]+/project) {
2022-11-01 21:41:26 +08:00
proxy_pass http://eoapi-remote-server:3000; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite "^/(.*)$" /api/$1 break;
}
# location ^~ /zh/(.*)/assets/(.*)$ {
# alias /usr/share/nginx/html/zh/assets/$2;
# return 501 /usr/share/nginx/html/zh/assets/$2;
#}
# location ^~ /zh/\.(gif|jpg|jpeg|png|css|js|ico|svg|ttf|woff2|woff|txt)$ {
# alias /usr/share/nginx/html/zh/$1;
# return 502 /usr/share/nginx/html/zh/$1;
#}
}