gpt4 book ai didi

nginx - "/"以外的路由无法运行 nginx

转载 作者:行者123 更新时间:2023-12-05 04:11:36 31 4
gpt4 key购买 nike

我的 Nginx 配置仅适用于根位置,所有其他位置都返回“Cannot GET {location}”,其中位置是域后地址的其余部分。

这是我的/etc/nginx/sites-enabled/default:

server {
listen 80;

server_name www.domain.net;

location / {
proxy_pass http://ip:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

location /api/ {
proxy_pass http://ip:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

为了测试,我在两个位置都设置了相同的 ip,但只有根位置有效。 我该如何解决这个问题?

最佳答案

尝试以下操作:

proxy_pass http://ip:3000/;

请注意结尾的斜杠。

关于nginx - "/"以外的路由无法运行 nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42457366/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com