NextChat
NextChat copied to clipboard
[Bug] Nginx subpath仍然不可用
反馈须知
请在下方中括号内输入 x 来表示你已经知晓相关内容。
描述问题 #693 subpath仍然不可用 已参考:1 2 麻烦作者了
如何复现
截图
一些必要的信息
- 系统:Centos Stream 8
- 浏览器:edge
- 版本: 2ec99bb
- 部署方式:docker
欢迎 pr:https://levelup.gitconnected.com/deploy-your-nextjs-application-on-a-different-base-path-i-e-not-root-1c4d210cce8a
支持 sub path 会让网络资源管理变得麻烦,所以我不准备支持此特性,如果未来找到了更好的方法,再做考虑。
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.
I solved it, let me outline the steps.
I used nginx
You need to add pathname to the code in these two places
支持 sub path 会让网络资源管理变得麻烦,所以我不准备支持此特性,如果未来找到了更好的方法,再做考虑。
建议作者考虑支持一下自定义 prefix。部署在根路径下,很容易被其他人撞到,,issue里就看到好几个这样的提问,建议作者考虑一下吧
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.
各种方法试了不少,无论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;
......
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;
...