问题描述:a 服务器的 nginx 服务会将 /aisp/approval/
路径的请求转发给我,我收到请求后根据user-agent
判断是移动端还是 pc 端请求,如果为移动端的,则去当前服务器的/home/centos/web/h5
目录下响应对应的静态文件。如果是/aisp/approval/api/
路径下的请求则请求后端服务,当前的配置:
server {
listen 9999;
server_name localhost;
location /aisp/approval/ {
if ($is_mobile = 0) {
rewrite ^/aisp/approval/(.*)$ https://b.com/$1 permanent;
}
alias /home/centos/web/h5/;
try_files $uri $uri/ /index.html;
}
location /aisp/approval/api/ {
limit_conn perip 1000;
proxy_pass http://10.156.166.23:9088/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
client_max_body_size 600M;
client_body_buffer_size 512k;
}
}
现在的问题是通过移动端请求a.com/aisp/approval/workOrder/orderHandlerDetails
,error.log 会报:
open() "/usr/local/nginx/html/home/centos/supervision/web/h5/index.html" failed (2: No such file or directory)
/usr/local/nginx/html 是我 nginx 的安装目录,我要如何配置才能在请求 a.com/aisp/approval/workOrder/时响应/home/centos/supervision/web/h5/目录下的 index.html
1
kingwrcy 12 天前
server {
listen 9999; server_name localhost; location /aisp/approval/ { if ($is_mobile = 0) { rewrite ^/aisp/approval/(.*)$ https://b.com/$1 permanent; } root /home/centos/web/h5; # 使用 root 指令 try_files $uri $uri/ /aisp/approval/index.html; # 确保指向正确的 index.html } location /aisp/approval/api/ { limit_conn perip 1000; proxy_pass http://10.156.166.23:9088/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; client_max_body_size 600M; client_body_buffer_size 512k; } } |
2
yippee0539 12 天前
啥了,想了半天没看到没有指定 root
楼上 nb |