(reopen issue) How to configure so that dify can be accessed through nginx domain name + path (for example: https://my.com/dify) #8286

Closed
opened 2026-02-21 18:24:53 -05:00 by yindo · 4 comments
Owner

Originally created by @xyfZzz on GitHub (Feb 15, 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

At present, I have referred to some historical replies in the issues and configured nginx corresponding to the domain name:

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

And the following variables in .env are set:

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

After deploying dify through docker compose, dify still cannot be accessed normally through https://my.com/dify/install or https://my.com/dify/apps.

Currently, the web page reports an error. When accessing js and css static files, it still returns a 304 error by accessing https://my.com/_next/... instead of accessing https://my.com/dify/_next/...

Is there any correct operation case for reference? Or is there still a bug?

✔️ Expected Behavior

Hope to successfully access dify through https://my.com/dify/install

Actual Behavior

Currently, the web page reports an error. When accessing js and css static files, you still go to https://my.com/_next/..., which results in a 304 error, instead of accessing https://my.com/dify/_next/...

Originally created by @xyfZzz on GitHub (Feb 15, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] 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 At present, I have referred to some historical replies in the issues and configured nginx corresponding to the domain name: ``` 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; } } ``` And the following variables in .env are set: ``` 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 ``` After deploying dify through docker compose, dify still cannot be accessed normally through https://my.com/dify/install or https://my.com/dify/apps. Currently, the web page reports an error. When accessing js and css static files, it still returns a 304 error by accessing https://my.com/_next/... instead of accessing https://my.com/dify/_next/... Is there any correct operation case for reference? Or is there still a bug? ### ✔️ Expected Behavior Hope to successfully access dify through https://my.com/dify/install ### ❌ Actual Behavior Currently, the web page reports an error. When accessing js and css static files, you still go to https://my.com/_next/..., which results in a 304 error, instead of accessing https://my.com/dify/_next/...
yindo added the 🐞 bug🤔 cant-reproduce labels 2026-02-21 18:24:53 -05:00
yindo closed this issue 2026-02-21 18:24:53 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 15, 2025):

To resolve the issue with accessing Dify through a domain name and path like https://my.com/dify, you need to configure the base path correctly in your Docker deployment. Here are the steps you should follow:

  1. Build a Custom Docker Image: You need to build a custom Docker image with the base path configuration. Navigate to the web directory of your Dify setup and run the following command:

    docker build . -t dify-base-path:latest --build-arg NEXT_PUBLIC_BASE_PATH=/dify
    

    This command sets the NEXT_PUBLIC_BASE_PATH to /dify, which ensures that the application correctly handles asset paths internally.

  2. Set Environment Variables: Ensure that the NEXT_PUBLIC_BASE_PATH environment variable is set to /dify during deployment. This is crucial for the Next.js application to generate the correct paths for static assets.

These steps should help in resolving the issue where static files are being requested from the root path instead of the specified sub-path [1].

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

@dosubot[bot] commented on GitHub (Feb 15, 2025): <!-- Answer --> To resolve the issue with accessing Dify through a domain name and path like `https://my.com/dify`, you need to configure the base path correctly in your Docker deployment. Here are the steps you should follow: 1. **Build a Custom Docker Image**: You need to build a custom Docker image with the base path configuration. Navigate to the `web` directory of your Dify setup and run the following command: ```bash docker build . -t dify-base-path:latest --build-arg NEXT_PUBLIC_BASE_PATH=/dify ``` This command sets the `NEXT_PUBLIC_BASE_PATH` to `/dify`, which ensures that the application correctly handles asset paths internally. 2. **Set Environment Variables**: Ensure that the `NEXT_PUBLIC_BASE_PATH` environment variable is set to `/dify` during deployment. This is crucial for the Next.js application to generate the correct paths for static assets. These steps should help in resolving the issue where static files are being requested from the root path instead of the specified sub-path <sup>[[1]](https://github.com/langgenius/dify/issues/13735)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/96c9492f-923b-47c7-8ba8-31561cbde60a?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/96c9492f-923b-47c7-8ba8-31561cbde60a?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/96c9492f-923b-47c7-8ba8-31561cbde60a?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/96c9492f-923b-47c7-8ba8-31561cbde60a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/96c9492f-923b-47c7-8ba8-31561cbde60a?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/96c9492f-923b-47c7-8ba8-31561cbde60a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/96c9492f-923b-47c7-8ba8-31561cbde60a?feedback_type=other)</sup>
Author
Owner

@xyfZzz commented on GitHub (Feb 15, 2025):

@deershark Thanks, I saw your reply https://github.com/langgenius/dify/issues/13735#issuecomment-2658734589. Is the image dify-base-path:latest generated according to the method mentioned in your reply used to replace the image langgenius/dify-web?

@xyfZzz commented on GitHub (Feb 15, 2025): @deershark Thanks, I saw your reply https://github.com/langgenius/dify/issues/13735#issuecomment-2658734589. Is the image `dify-base-path:latest` generated according to the method mentioned in your reply used to replace the image `langgenius/dify-web`?
Author
Owner

@deershark commented on GitHub (Feb 15, 2025):

@deershark Thanks, I saw your reply #13735 (comment). Is the image dify-base-path:latest generated according to the method mentioned in your reply used to replace the image langgenius/dify-web?

yes! only need to replace this image

@deershark commented on GitHub (Feb 15, 2025): > [@deershark](https://github.com/deershark) Thanks, I saw your reply [#13735 (comment)](https://github.com/langgenius/dify/issues/13735#issuecomment-2658734589). Is the image `dify-base-path:latest` generated according to the method mentioned in your reply used to replace the image `langgenius/dify-web`? yes! only need to replace this image
Author
Owner

@crazywoola commented on GitHub (Feb 15, 2025):

This is only for bug report, if you would like to ask a question, please head to Discussions.

@crazywoola commented on GitHub (Feb 15, 2025): This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8286