Can the nginx of dify implement forwarding requests to the web and API through sub paths #6076
Replies: 2 comments 12 replies
-
To configure Nginx to forward requests to the web and API through sub-paths without encountering 404 errors, you can use the following configuration as a reference: server {
listen 80;
server_name _;
location /difyserver/console/api {
proxy_pass http://api:5001/console/api;
include proxy.conf;
}
location /difyserver/api {
proxy_pass http://api:5001/api;
include proxy.conf;
}
location /difyserver/v1 {
proxy_pass http://api:5001/v1;
include proxy.conf;
}
location /difyserver/files {
proxy_pass http://api:5001/files;
include proxy.conf;
}
location /difyserver/ {
proxy_pass http://web:3000/;
include proxy.conf;
}
# If you want to support HTTPS, please uncomment the code snippet below
#listen 443 ssl;
#ssl_certificate ./../ssl/your_cert_file.cer;
#ssl_certificate_key ./../ssl/your_cert_key.key;
#ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
#ssl_prefer_server_ciphers on;
#ssl_session_cache shared:SSL:10m;
#ssl_session_timeout 10m;
} This configuration ensures that:
Make sure that the Additionally, ensure that the environment variables in your web:
image: langgenius/dify-web:0.6.12
restart: always
environment:
CONSOLE_API_URL: 'http://yourdomain.com/difyserver/console'
APP_API_URL: 'http://yourdomain.com/difyserver/app' And in your CONSOLE_API_URL=http://yourdomain.com/difyserver/console
CONSOLE_WEB_URL=http://yourdomain.com/difyserver/console
APP_WEB_URL=http://yourdomain.com/difyserver/app These configurations ensure that the Dify web application is aware of the base URLs and any sub-paths configured [3][4][5][6]. |
Beta Was this translation helpful? Give feedback.
-
To configure Nginx to forward requests to the web and API through sub-paths without encountering 404 errors, you can use the following configuration as a reference: server {
listen 80;
server_name _;
location /difyserver/console/api {
proxy_pass http://api:5001/console/api;
include proxy.conf;
}
location /difyserver/api {
proxy_pass http://api:5001/api;
include proxy.conf;
}
location /difyserver/v1 {
proxy_pass http://api:5001/v1;
include proxy.conf;
}
location /difyserver/files {
proxy_pass http://api:5001/files;
include proxy.conf;
}
location /difyserver/ {
proxy_pass http://web:3000/;
include proxy.conf;
}
# If you want to support HTTPS, please uncomment the code snippet below
#listen 443 ssl;
#ssl_certificate ./../ssl/your_cert_file.cer;
#ssl_certificate_key ./../ssl/your_cert_key.key;
#ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
#ssl_prefer_server_ciphers on;
#ssl_session_cache shared:SSL:10m;
#ssl_session_timeout 10m;
} This configuration ensures that:
Make sure that the Additionally, ensure that the environment variables in your web:
image: langgenius/dify-web:0.6.12
restart: always
environment:
CONSOLE_API_URL: 'http://yourdomain.com/difyserver/console'
APP_API_URL: 'http://yourdomain.com/difyserver/app' And in your CONSOLE_API_URL=http://yourdomain.com/difyserver/console
CONSOLE_WEB_URL=http://yourdomain.com/difyserver/console
APP_WEB_URL=http://yourdomain.com/difyserver/app These configurations ensure that the Dify web application is aware of the base URLs and any sub-paths configured [3][4][5][6]. |
Beta Was this translation helpful? Give feedback.
-
Self Checks
Dify version
0.6.11
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
When I start the service based on the default nginx configuration file and it can be accessed normally, the default nginx configuration is as follows:




But I have a problem that the root path of the domain name has already been used, so I want to add sub paths to all location forwarding paths in the nginx configuration, such as location/diffyserver/, The specific configuration is as follows:
After I made the configuration changes and restarted the service, the browser accessed http://ip:port/difyserver Address, page cannot be displayed properly, page displays 404
✔️ Expected Behavior
I hope the above methods can be supported
❌ Actual Behavior
No response
Beta Was this translation helpful? Give feedback.
All reactions