Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Nginx subpath仍然不可用 #720

Closed
singledog957 opened this issue Apr 11, 2023 · 9 comments
Closed

[Bug] Nginx subpath仍然不可用 #720

singledog957 opened this issue Apr 11, 2023 · 9 comments

Comments

@singledog957
Copy link

singledog957 commented Apr 11, 2023

反馈须知

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

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

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

如何复现

截图

一些必要的信息

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

Yidadaa commented Apr 11, 2023

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

@ttimasdf
Copy link

ttimasdf commented May 15, 2023

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

Traefik StripPrefix Documentation - Traefik

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jun 23, 2023

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

@Yidadaa Yidadaa closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2023
@Issues-translate-bot
Copy link

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.

@hellohejinyu
Copy link

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

@leeyoshinari
Copy link

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

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

@Issues-translate-bot
Copy link

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.

@Nonosword
Copy link

各种方法试了不少,无论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;
    ......

@Issues-translate-bot
Copy link

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;
    ...  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants