how to update nginx/conf.d/default.conf,if modify directly ,will replace #6028

Closed
opened 2026-02-21 18:13:45 -05:00 by yindo · 2 comments
Owner

Originally created by @tonyliu088 on GitHub (Oct 10, 2024).

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.8.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

i want to change http://api:5001 and http://web:3000 ,where to change?
i got this error :
has been blocked by CORS policy: Response to preflight request doesn't pass access control check:

✔️ Expected Behavior

No response

Actual Behavior

i want to change http://api:5001 and http://web:3000 ,where to change?
i got this error :
has been blocked by CORS policy: Response to preflight request doesn't pass access control check:

Originally created by @tonyliu088 on GitHub (Oct 10, 2024). ### 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.8.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce i want to change http://api:5001 and http://web:3000 ,where to change? i got this error : has been blocked by CORS policy: Response to preflight request doesn't pass access control check: ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior i want to change http://api:5001 and http://web:3000 ,where to change? i got this error : has been blocked by CORS policy: Response to preflight request doesn't pass access control check:
yindo added the 🙋‍♂️ question label 2026-02-21 18:13:45 -05:00
yindo closed this issue 2026-02-21 18:13:45 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 10, 2024):

To update nginx/conf.d/default.conf without it being replaced, modify the relevant .env variables. This ensures your changes are preserved when the configuration is regenerated.

For resolving the CORS policy error, update the URLs in the .env file to point to the correct endpoints. Set the placeholders like ${NGINX_PORT} and ${NGINX_SERVER_NAME} in the .env file:

NGINX_PORT=your_port
NGINX_SERVER_NAME=your_server_name

Additionally, you can add CORS headers directly in the default.conf:

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept';

Place these in the appropriate location block to handle CORS for specific paths [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 10, 2024): <!-- Answer --> To update `nginx/conf.d/default.conf` without it being replaced, modify the relevant `.env` variables. This ensures your changes are preserved when the configuration is regenerated. For resolving the CORS policy error, update the URLs in the `.env` file to point to the correct endpoints. Set the placeholders like `${NGINX_PORT}` and `${NGINX_SERVER_NAME}` in the `.env` file: ```env NGINX_PORT=your_port NGINX_SERVER_NAME=your_server_name ``` Additionally, you can add CORS headers directly in the `default.conf`: ```conf add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept'; ``` Place these in the appropriate `location` block to handle CORS for specific paths <sup>[[1]](https://github.com/langgenius/dify/blob/main/docker/nginx/conf.d/default.conf.template)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@tonyliu088 commented on GitHub (Oct 10, 2024):

if add add_header 'Access-Control-Allow-Origin' '*'; directly, after docker compose up -d ,it will be repalced;

@tonyliu088 commented on GitHub (Oct 10, 2024): if add add_header 'Access-Control-Allow-Origin' '*'; directly, after docker compose up -d ,it will be repalced;
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6028