ChatGPT-Next-Web 我怎么设置他成为一个子目录呢?nginx

btqmn9zl  于 1个月前  发布在  Nginx
关注(0)|答案(9)|浏览(95)

我想访问我主站的/gpt路径,代理这个地址。
测试了下404,资料加载不了。

location /gpt {
 proxy_pass [http://127.0.0.1:6003/](http://127.0.0.1:6003/);
 proxy_buffering off;
 proxy_read_timeout 100s;
}
xkrw2x1b

xkrw2x1b1#

请按照 issue template 更新您问题的主题和描述。

hmtdttj4

hmtdttj42#

Bot detected the issue body's language is not English, translate it automatically.

Title: How do I set it to be a subdirectory? nginx

v1l68za4

v1l68za43#

在这里也有同样的问题。

gdrx4gfi

gdrx4gfi4#

请尝试以下代码:

server {
listen 80;
server_name _;
location ~ /(_next|config|google-fonts|serviceWorkerRegister) {
proxy_pass http://nextchat:3000;
}
location /chat {
rewrite /chat/(.*) /$1 break;
proxy_pass http://nextchat:3000;
proxy_buffering off;
proxy_read_timeout 100s;
}
}

pb3s4cty

pb3s4cty5#

另一个版本:

server {
    listen       80;
    server_name _;
    location / {
        # can serve other site files, and try "@chat" at last
        try_files $uri $uri/ @chat;
    }
    location @chat {
        rewrite /chat/(.*) /$1 break;
        proxy_pass http://nextchat:3000;
        proxy_buffering off;
        proxy_read_timeout 100s;
    }
}
vnzz0bqm

vnzz0bqm6#

另一个版本:

server {
    listen       80;
    server_name _;
    location / {
        # can serve other site files, and try "@chat" at last
        try_files $uri $uri/ @chat;
    }
    location @chat {
        rewrite /chat/(.*) /$1 break;
        proxy_pass http://nextchat:3000;
        proxy_buffering off;
        proxy_read_timeout 100s;
    }
}

这肯定行不通,因为我的主路径上有其他网站,我只是想让它们成为我网站的一部分。

m4pnthwp

m4pnthwp7#

请尝试以下内容:

server {
    listen       80;
    server_name _;
    location ~ /(_next|config|google-fonts|serviceWorkerRegister) {
        proxy_pass http://nextchat:3000;
    }
    location /chat {
        rewrite /chat/(.*) /$1 break;
        proxy_pass http://nextchat:3000;
        proxy_buffering off;
        proxy_read_timeout 100s;
    }
}

[紧急] 2408809#2408809: "proxy_pass" 不能在由正则表达式给出的位置、命名位置、"if"语句或"limit_except"块中包含URI部分。

lndjwyie

lndjwyie9#

https://gist.github.com/lloydzhou/1bd2f63a85e5a622716d001a3a9c5a8d
第二个版本,运行正常

我的意思是你的根目录不能用于其他网站的反向代理,对吗?

相关问题