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

如何配置才能使得通过nginx的域名+path(比如:https://my.com/dify)进行代理访问到dify #13735

Closed
5 tasks done
xyfZzz opened this issue Feb 14, 2025 · 12 comments

Comments

@xyfZzz
Copy link

xyfZzz commented Feb 14, 2025

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

目前我参考了issue中的一些历史答复,将域名对应的nginx进行了配置:

server {
    listen 80;
    server_name my.com;

    location /dify/ {
        proxy_pass http://127.0.0.1:8090/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Prefix /dify;
        rewrite ^/dify/(.*)$ /$1 break;
    }
}

并且在.env中的如下一些变量进行了设置:

CONSOLE_API_URL=https://my.com/dify/api
CONSOLE_WEB_URL=https://my.com/dify
SERVICE_API_URL=https://my.com/dify/service
APP_API_URL=https://my.com/dify/app
APP_WEB_URL=https://my.com/dify

并对dify通过docker compose部署后,依旧无法通过https://my.com/dify/install或https://my.com/dify/apps正常访问到dify。

目前网页报错,访问js和css静态文件时还是去访问https://my.com/_next/...导致返回304错误,而不是访问https://my.com/dify/_next/...

请问有没有正确的操作案例可供参考?还是说目前还有bug?

✔️ Expected Behavior

希望通过https://my.com/dify/install成功访问到dify

❌ Actual Behavior

目前网页报错,访问js和css静态文件时还是去访问https://my.com/_next/...导致返回304错误,而不是访问https://my.com/dify/_next/...

Copy link

dosubot bot commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].

  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].

  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@xyfZzz
Copy link
Author

xyfZzz commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.

To continue talking to Dosu, mention @dosu.

Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

@deershark
Copy link

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

I followed the NextJS rules, added sub-path environment variables to support (need to re-package and deploy), corrected the front-end resources and some redirect routes, and did not encounter any major problems in my personal use. I submitted a PR but the official has not reviewed it yet...

#13394

@dc-vin
Copy link

dc-vin commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

Image
我这边原本服务器有nginx已经占用了端口,我的做法是把dify的nginx暴露的端口改掉,然后把原本服务器nginx代理到dify的nginx。

@xyfZzz
Copy link
Author

xyfZzz commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

Image 我这边原本服务器有nginx已经占用了端口,我的做法是把dify的nginx暴露的端口改掉,然后把原本服务器nginx代理到dify的nginx。

大佬,我也是用原本服务器的nginx代理到dify的nginx'http://127.0.0.1:8090/',但是配置的转发路径不是'/',而是'/dify',我是通过域名+"/dify/install"进行访问,但是网页端访问时静态文件还是通过域名+"/_next"进行访问,而不是通过域名+"/dify/_next"进行访问,从而出现了报错

@dc-vin
Copy link

dc-vin commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

Image 我这边原本服务器有nginx已经占用了端口,我的做法是把dify的nginx暴露的端口改掉,然后把原本服务器nginx代理到dify的nginx。

大佬,我也是用原本服务器的nginx代理到dify的nginx'http://127.0.0.1:8090/',但是配置的转发路径不是'/',而是'/dify',我是通过域名+"/dify/install"进行访问,但是网页端访问时静态文件还是通过域名+"/_next"进行访问,而不是通过域名+"/dify/_next"进行访问,从而出现了报错

这种nginx配置问题问下gpt就能解决吧

@xyfZzz
Copy link
Author

xyfZzz commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

I followed the NextJS rules, added sub-path environment variables to support (need to re-package and deploy), corrected the front-end resources and some redirect routes, and did not encounter any major problems in my personal use. I submitted a PR but the official has not reviewed it yet...

#13394

大佬牛逼啊,目前有可用的镜像进行替换吗?

@dc-vin
Copy link

dc-vin commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

I followed the NextJS rules, added sub-path environment variables to support (need to re-package and deploy), corrected the front-end resources and some redirect routes, and did not encounter any major problems in my personal use. I submitted a PR but the official has not reviewed it yet...
#13394

大佬牛逼啊,目前有可用的镜像进行替换吗?

你为啥不改原本服务器的ningx配置,而要去改dify的nginx配置?

@xyfZzz
Copy link
Author

xyfZzz commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

Image 我这边原本服务器有nginx已经占用了端口,我的做法是把dify的nginx暴露的端口改掉,然后把原本服务器nginx代理到dify的nginx。

大佬,我也是用原本服务器的nginx代理到dify的nginx'http://127.0.0.1:8090/',但是配置的转发路径不是'/',而是'/dify',我是通过域名+"/dify/install"进行访问,但是网页端访问时静态文件还是通过域名+"/_next"进行访问,而不是通过域名+"/dify/_next"进行访问,从而出现了报错

这种nginx配置问题问下gpt就能解决吧

感觉这种跟前端技术有关吧,nginx再怎么配应该也搞不定,而且我不会任何前端技术,所以还是实事求是提issue比较好,如果问gpt一下就能解决,感觉这种问题应该也不至于存在到现在还没被解决了。

@xyfZzz
Copy link
Author

xyfZzz commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

I followed the NextJS rules, added sub-path environment variables to support (need to re-package and deploy), corrected the front-end resources and some redirect routes, and did not encounter any major problems in my personal use. I submitted a PR but the official has not reviewed it yet...
#13394

大佬牛逼啊,目前有可用的镜像进行替换吗?

你为啥不改原本服务器的ningx配置,而要去改dify的nginx配置?

我没有改dify的nginx配置,我改的就是原本服务器的ningx配置

@deershark
Copy link

deershark commented Feb 14, 2025

I found some similar discussions that might be helpful for your issue with configuring Nginx to proxy requests to Dify using a domain and path:

  1. How can I set up dify server behind a nginx reverse proxy? - This discussion is still open and might contain relevant information for setting up Nginx with Dify [1].
  2. Can the nginx of dify implement forwarding requests to the web and API through sub paths - This is another open discussion that could provide insights into configuring Nginx for subpath forwarding [2].
  3. nginx如何配置以下域名代理,例如:https://my.com/dify/作为系统入口,现在占用根域名/导致其他系统异常 - This closed issue might have some configuration examples or solutions that were discussed [3].

These threads might contain configuration examples or solutions that could help resolve the issue with accessing static files through the correct path.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

这些讨论都没有解决这个问题啊?为什么这个问题这么多人提出且持续了这么久,但是都没有被解决呢?

I followed the NextJS rules, added sub-path environment variables to support (need to re-package and deploy), corrected the front-end resources and some redirect routes, and did not encounter any major problems in my personal use. I submitted a PR but the official has not reviewed it yet...
#13394

大佬牛逼啊,目前有可用的镜像进行替换吗?

自定义子路径的话,这个需要自己编镜像,拉我fork的仓库,进入 web 文件夹,然后指令:docker build . -t dify-base-path:latest --build-arg NEXT_PUBLIC_BASE_PATH=/custom-path (/custom-path改成自己的路径)就好了,部署的时候也要把 NEXT_PUBLIC_BASE_PATH 环境变量加上

@langgenius langgenius locked as off-topic and limited conversation to collaborators Feb 14, 2025
@crazywoola
Copy link
Member

Close due to #1542

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

No branches or pull requests

4 participants