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

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

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

  1. location /gpt {
  2. proxy_pass [http://127.0.0.1:6003/](http://127.0.0.1:6003/);
  3. proxy_buffering off;
  4. proxy_read_timeout 100s;
  5. }
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#

另一个版本:

  1. server {
  2. listen 80;
  3. server_name _;
  4. location / {
  5. # can serve other site files, and try "@chat" at last
  6. try_files $uri $uri/ @chat;
  7. }
  8. location @chat {
  9. rewrite /chat/(.*) /$1 break;
  10. proxy_pass http://nextchat:3000;
  11. proxy_buffering off;
  12. proxy_read_timeout 100s;
  13. }
  14. }
vnzz0bqm

vnzz0bqm6#

另一个版本:

  1. server {
  2. listen 80;
  3. server_name _;
  4. location / {
  5. # can serve other site files, and try "@chat" at last
  6. try_files $uri $uri/ @chat;
  7. }
  8. location @chat {
  9. rewrite /chat/(.*) /$1 break;
  10. proxy_pass http://nextchat:3000;
  11. proxy_buffering off;
  12. proxy_read_timeout 100s;
  13. }
  14. }

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

展开查看全部
m4pnthwp

m4pnthwp7#

请尝试以下内容:

  1. server {
  2. listen 80;
  3. server_name _;
  4. location ~ /(_next|config|google-fonts|serviceWorkerRegister) {
  5. proxy_pass http://nextchat:3000;
  6. }
  7. location /chat {
  8. rewrite /chat/(.*) /$1 break;
  9. proxy_pass http://nextchat:3000;
  10. proxy_buffering off;
  11. proxy_read_timeout 100s;
  12. }
  13. }

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

lndjwyie

lndjwyie9#

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

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

相关问题