配置了 nginx
server {
listen 80;
server_name test.abc.com;
location /app {
rewrite /app(.*) $1 break;
proxy_pass http://123456.gradio.app;
proxy_set_header Host "123456.gradio.app";
}
location / {
return 200 "ok";
}
}
访问 http://test.abc.com/app 出现下面的错误
2022/12/05 22:02:18 [error] 17130#0: *5 the rewritten URI has a zero length,
client: 127.0.0.1,
server: test.abc.com,
request: "GET /app HTTP/1.1",
host: "test.abc.com"
原因:转发时,请求空路径到 proxy,解决方案:
server {
listen 80;
server_name test.abc.com;
location /app/ {
rewrite /app(.*) $1 break;
proxy_pass http://123456.gradio.app;
proxy_set_header Host "123456.gradio.app";
}
location / {
return 200 "ok";
}
}
把 location /app 改成了 location /app/