langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
50.97k stars 7.33k forks source link

Failed to launch front-end Docker container separately #8271

Closed jivaklong closed 4 weeks ago

jivaklong commented 1 month ago

Self Checks

Provide a description of requested docs changes

Start the front-end Docker container separately cd web && docker build . -t dify-web docker run -it -p 3000:3000 -e CONSOLE_API_URL= http://127.0.0.1:5001 -e APP_API_URL= http://127.0.0.1:5001 dify-web

The deployment of Docker Compose on the server has been completed and can run normally. Stop the original DIY web container and run the command above. When opening the website, an error message appears below

502 Bad Gateway nginx/1.27.1

dosubot[bot] commented 1 month ago

I found some similar issues and discussions that might help you resolve the "502 Bad Gateway" error when launching the front-end Docker container separately:

  1. I can't access localhost/install and get a 502 Bad Gateway after deploying the docker (closed):

    • Solution: Ensure all Docker containers are running and update the Nginx configuration with the correct IP addresses of the docker-web-1 and docker-api-1 containers. Restart the Nginx container to apply the changes [1].
  2. Changes made to frontend not showing up when app run locally using Docker (closed):

    • Solution: Ensure entrypoint.sh is in UNIX format, set the correct environment variables (CONSOLE_URL and APP_URL), and verify file permissions. Properly configure the Dockerfile to copy and set the entrypoint script [2].
  3. repack images but 502 bad gateway (closed):

    • Solution: Check application logs, Docker Compose file, and application code. Rebuild the Docker image and restart the Docker containers. Review and correct the entrypoint.sh script if necessary [3].

To resolve your specific issue, follow these steps:

  1. Ensure Containers are Running:

    docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
  2. Update Nginx Configuration:

    • Identify the IP addresses for docker-web-1 and docker-api-1.
    • Open the Nginx configuration file located at dify/docker/nginx/conf.d.
    • Replace http://api:5001 with http://<docker-api-1 IP>:5001 and http://web:3000 with http://<docker-web-1 IP>:3000.
  3. Restart Nginx:

    docker compose restart nginx
  4. Run the Frontend Container:

    docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 dify-web

These steps should help you resolve the "502 Bad Gateway" error by ensuring Nginx forwards requests to the correct IP addresses of the running containers and by properly configuring the frontend service [1][2][3].

To continue talking to Dosu, mention @dosu.

crazywoola commented 1 month ago

Please attach the container logs as well. What did you changed?

jivaklong commented 1 month ago

This is done through Docker ps-a and Docker logs 7e8c81f35aec (viewing my-dify-web), where my-dify-web is a locally created image.

image image
crazywoola commented 1 month ago

I think 502 Bad Gateway is due to the server isn't started up properly.

jivaklong commented 1 month ago

Using docker images view:

image

Using Docker PS - a, check that my-dify-web Status is up and in the started state .

image image

If I run the commands docker stop 7e8c81f35aec (stop my-dify-web), docker start e6bf2af75e45 (start langgenius/dify-web: 0.7.3), the webpage will pass through http://localhost:8070/ Can be opened normally. But I want to start the frontend Docker container separately

image image
jivaklong commented 1 month ago

The above code only modifies a few places for testing, and then runs the command:docker build . -t dify-web docker run -d -p 3000:3000 -e CONSOLE_API_URL= http://127.0.0.1:5001/ -e APP_API_URL= http://127.0.0.1:5001/ dify-web

image