ChatGPT-Next-Web icon indicating copy to clipboard operation
ChatGPT-Next-Web copied to clipboard

[Bug] Nginx subpath仍然不可用

Open singledog957 opened this issue 1 year ago • 3 comments

反馈须知

请在下方中括号内输入 x 来表示你已经知晓相关内容。

  • [ x] 我确认已经在 常见问题 中搜索了此次反馈的问题,没有找到解答;
  • [x ] 我确认已经在 Issues 列表(包括已经 Close 的)中搜索了此次反馈的问题,没有找到解答。

描述问题 #693 subpath仍然不可用 已参考:1 2 麻烦作者了

如何复现

截图

一些必要的信息

  • 系统:Centos Stream 8
  • 浏览器:edge
  • 版本: 2ec99bb
  • 部署方式:docker

singledog957 avatar Apr 11 '23 09:04 singledog957

欢迎 pr:https://levelup.gitconnected.com/deploy-your-nextjs-application-on-a-different-base-path-i-e-not-root-1c4d210cce8a

Yidadaa avatar Apr 11 '23 10:04 Yidadaa

可以在反代侧,把 sub path strip 掉,不建议用 nginx 部署任何 docker 服务。

Traefik StripPrefix Documentation - Traefik

ttimasdf avatar May 15 '23 02:05 ttimasdf

支持 sub path 会让网络资源管理变得麻烦,所以我不准备支持此特性,如果未来找到了更好的方法,再做考虑。

Yidadaa avatar Jun 23 '23 17:06 Yidadaa

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


Supporting sub path will make network resource management cumbersome, so I don't plan to support this feature. If a better method is found in the future, I will consider it.

Issues-translate-bot avatar Jun 23 '23 17:06 Issues-translate-bot

image I solved it, let me outline the steps.

I used nginx

image

You need to add pathname to the code in these two places

image

hellohejinyu avatar Jan 12 '24 14:01 hellohejinyu

支持 sub path 会让网络资源管理变得麻烦,所以我不准备支持此特性,如果未来找到了更好的方法,再做考虑。

建议作者考虑支持一下自定义 prefix。部署在根路径下,很容易被其他人撞到,,issue里就看到好几个这样的提问,建议作者考虑一下吧

leeyoshinari avatar Jan 20 '24 00:01 leeyoshinari

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


Supporting sub path will make network resource management cumbersome, so I am not planning to support this feature. If a better method is found in the future, I will consider it.

It is recommended that the author consider supporting custom prefix. Deployed under the root path, it is easy to be bumped into by others. I saw several such questions in the issue. I suggest the author consider it.

Issues-translate-bot avatar Jan 20 '24 00:01 Issues-translate-bot

各种方法试了不少,无论docker还是got clone来部署,对于nginx +subpath方式的支持都不太友好。 所以最好的方法就是用 subdomain,然后加个http auth,防止被直接扫到,和subpath效果一样。 nginx里监控分别跟踪子域名和主域名,子域名对http加auth basic,对api忽略auth:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name ai.xxxxxx.com;
    ssl_certificate
    ......

    auth_basic "Restricted Content";
    auth_basic_user_file /etc/nginx/.htpasswd;

    location ^~ /api/ {
        auth_basic off;
        proxy_pass http://localhost:3000;
    }

    # chatgpt-next-web 配置
    location / {
        proxy_pass http://localhost:3000/;
    }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name xxxxxx.com *.xxxxxx.com;
    ......

Nonosword avatar Apr 10 '24 09:04 Nonosword

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


I have tried a lot of various methods, and whether it is deployed with docker or got clone, the support for nginx + subpath is not very friendly. So the best way is to use subdomain and then add http auth to prevent it from being scanned directly. It has the same effect as subpath. Monitoring in nginx tracks subdomain names and main domain names respectively. Subdomain names add auth basic to http and ignore auth to api:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name ai.xxxxxx.com;
    ssl_certificate
    ...

    auth_basic "Restricted Content";
    auth_basic_user_file /etc/nginx/.htpasswd;

    location ^~ /api/ {
        auth_basic off;
        proxy_pass http://localhost:3000;
    }

    # chatgpt-next-web configuration
    location/{
        proxy_pass http://localhost:3000/;
    }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name xxxxxx.com *.xxxxxx.com;
    ...  
  

Issues-translate-bot avatar Apr 10 '24 09:04 Issues-translate-bot