API page, run page and embeding page use the default port 80/443 in url instead of using the custom http/https port when self hosting #13523

Closed
opened 2026-02-21 19:12:32 -05:00 by yindo · 3 comments
Owner

Originally created by @GeorgeCaoJ on GitHub (Apr 29, 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

1.2.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

change the default value of EXPOSE_NGINX_PORT and EXPOSE_NGINX_SSL_PORT in .env when hosting by docker

✔️ Expected Behavior

API page show the URL with the target port
App run entry will open a new page with the target port in the url to avoid 404
Embeding page show the corrent URL with target port

Actual Behavior

  1. Current API doc page:
    Image
  2. App run entry opens a new 404 page with URL:
    http://10.19.150.127/workflow/x55fPcBuM7fWUKNI
    Image
  3. Embed code example:
    Image
Originally created by @GeorgeCaoJ on GitHub (Apr 29, 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 1.2.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce change the default value of EXPOSE_NGINX_PORT and EXPOSE_NGINX_SSL_PORT in .env when hosting by docker ### ✔️ Expected Behavior API page show the URL with the target port App run entry will open a new page with the target port in the url to avoid 404 Embeding page show the corrent URL with target port ### ❌ Actual Behavior 1. Current API doc page: ![Image](https://github.com/user-attachments/assets/9bbc9a3f-cbb0-4e4f-b4f9-37f61100b8bb) 2. App run entry opens a new 404 page with URL: http://10.19.150.127/workflow/x55fPcBuM7fWUKNI ![Image](https://github.com/user-attachments/assets/5cf51c47-3d4a-4b3d-8b84-6cef9d798ee4) 3. Embed code example: ![Image](https://github.com/user-attachments/assets/e9304e16-1206-4d35-8c63-00bbfb5b3256)
yindo added the 🐞 bug label 2026-02-21 19:12:32 -05:00
yindo closed this issue 2026-02-21 19:12:32 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 29, 2025):

To address the issue of custom HTTP/HTTPS ports not being reflected in the URLs when self-hosting with Docker, you can follow these steps:

  1. Modify the APP_WEB_URL Environment Variable: Update your .env file to include your server IP and custom port number using the format: APP_WEB_URL=http://ip:port.

  2. Adjust Port Variables: Change the EXPOSE_NGINX_PORT and EXPOSE_NGINX_SSL_PORT variables in your .env file to your desired port numbers to resolve any port conflicts.

  3. Update Nginx Configuration: Modify the nginx/proxy.conf.template in the dify/docker directory by changing the Host header to $http_host:

    proxy_set_header Host $http_host;
    
  4. Docker Compose Configuration: Add the following configuration under x-shared-env in your docker-compose.yaml:

    x-shared-env: &shared-api-worker-env
      RESPECT_XFORWARD_HEADERS_ENABLED: true
    
  5. Squid Proxy Configuration: If you encounter issues with HTTPS requests on custom ports, such as 403 Forbidden errors, access the ssrf_proxy container, edit /etc/squid/squid.conf, and add the line: acl SSL_ports port 1025-65535. Then reload the configuration with: squid -k reconfigure.

These changes should ensure that the URLs reflect the custom ports and allow HTTPS requests to work on non-standard ports in your Docker deployment [1][2][3].

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 (Apr 29, 2025): <!-- Answer --> To address the issue of custom HTTP/HTTPS ports not being reflected in the URLs when self-hosting with Docker, you can follow these steps: 1. **Modify the `APP_WEB_URL` Environment Variable**: Update your `.env` file to include your server IP and custom port number using the format: `APP_WEB_URL=http://ip:port`. 2. **Adjust Port Variables**: Change the `EXPOSE_NGINX_PORT` and `EXPOSE_NGINX_SSL_PORT` variables in your `.env` file to your desired port numbers to resolve any port conflicts. 3. **Update Nginx Configuration**: Modify the `nginx/proxy.conf.template` in the dify/docker directory by changing the Host header to `$http_host`: ```nginx proxy_set_header Host $http_host; ``` 4. **Docker Compose Configuration**: Add the following configuration under `x-shared-env` in your `docker-compose.yaml`: ```yaml x-shared-env: &shared-api-worker-env RESPECT_XFORWARD_HEADERS_ENABLED: true ``` 5. **Squid Proxy Configuration**: If you encounter issues with HTTPS requests on custom ports, such as 403 Forbidden errors, access the `ssrf_proxy` container, edit `/etc/squid/squid.conf`, and add the line: `acl SSL_ports port 1025-65535`. Then reload the configuration with: `squid -k reconfigure`. These changes should ensure that the URLs reflect the custom ports and allow HTTPS requests to work on non-standard ports in your Docker deployment <sup>[[1]](https://github.com/langgenius/dify/issues/14437)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/13480)</sup><sup>[[3]](https://github.com/langgenius/dify/issues/12792)</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/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Apr 29, 2025):

Please check the environment settings in the documentation. https://docs.dify.ai/en/getting-started/install-self-hosted/environments#app-api-url

@crazywoola commented on GitHub (Apr 29, 2025): Please check the environment settings in the documentation. https://docs.dify.ai/en/getting-started/install-self-hosted/environments#app-api-url
Author
Owner

@shaoyucheng commented on GitHub (May 6, 2025):

To address the issue of custom HTTP/HTTPS ports not being reflected in the URLs when self-hosting with Docker, you can follow these steps:

  1. Modify the APP_WEB_URL Environment Variable: Update your .env file to include your server IP and custom port number using the format: APP_WEB_URL=http://ip:port.
  2. Adjust Port Variables: Change the EXPOSE_NGINX_PORT and EXPOSE_NGINX_SSL_PORT variables in your .env file to your desired port numbers to resolve any port conflicts.
  3. Update Nginx Configuration: Modify the nginx/proxy.conf.template in the dify/docker directory by changing the Host header to $http_host:
    proxy_set_header Host $http_host;
  4. Docker Compose Configuration: Add the following configuration under x-shared-env in your docker-compose.yaml:
    x-shared-env: &shared-api-worker-env
    RESPECT_XFORWARD_HEADERS_ENABLED: true
  5. Squid Proxy Configuration: If you encounter issues with HTTPS requests on custom ports, such as 403 Forbidden errors, access the ssrf_proxy container, edit /etc/squid/squid.conf, and add the line: acl SSL_ports port 1025-65535. Then reload the configuration with: squid -k reconfigure.

These changes should ensure that the URLs reflect the custom ports and allow HTTPS requests to work on non-standard ports in your Docker deployment [1][2][3].

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

useful guides but it's not necessary to do all, the simplest way only needs two steps:

a. step 2: modify the expose port of nginx
b. step 3: modify the host in http header passed to backends

I have tested it and make sure it works as expected.

In my opinion,it's not suggested to modify the variable APP_WEB_URL and other XXX_URLs,because it directly affects the backends codes and can't adapt the various hostnames bounded in different environments。

@shaoyucheng commented on GitHub (May 6, 2025): > To address the issue of custom HTTP/HTTPS ports not being reflected in the URLs when self-hosting with Docker, you can follow these steps: > > 1. **Modify the `APP_WEB_URL` Environment Variable**: Update your `.env` file to include your server IP and custom port number using the format: `APP_WEB_URL=http://ip:port`. > 2. **Adjust Port Variables**: Change the `EXPOSE_NGINX_PORT` and `EXPOSE_NGINX_SSL_PORT` variables in your `.env` file to your desired port numbers to resolve any port conflicts. > 3. **Update Nginx Configuration**: Modify the `nginx/proxy.conf.template` in the dify/docker directory by changing the Host header to `$http_host`: > proxy_set_header Host $http_host; > 4. **Docker Compose Configuration**: Add the following configuration under `x-shared-env` in your `docker-compose.yaml`: > x-shared-env: &shared-api-worker-env > RESPECT_XFORWARD_HEADERS_ENABLED: true > 5. **Squid Proxy Configuration**: If you encounter issues with HTTPS requests on custom ports, such as 403 Forbidden errors, access the `ssrf_proxy` container, edit `/etc/squid/squid.conf`, and add the line: `acl SSL_ports port 1025-65535`. Then reload the configuration with: `squid -k reconfigure`. > > These changes should ensure that the URLs reflect the custom ports and allow HTTPS requests to work on non-standard ports in your Docker deployment [[1]](https://github.com/langgenius/dify/issues/14437)[[2]](https://github.com/langgenius/dify/issues/13480)[[3]](https://github.com/langgenius/dify/issues/12792). > > _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu)._ > > Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3d06fb76-b4e1-401a-ac14-7be60ebe624a?feedback_type=other) useful guides but it's not necessary to do all, the simplest way only needs two steps: a. step 2: modify the expose port of nginx b. step 3: modify the host in http header passed to backends I have tested it and make sure it works as expected. In my opinion,it's not suggested to modify the variable APP_WEB_URL and other XXX_URLs,because it directly affects the backends codes and can't adapt the various hostnames bounded in different environments。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13523