使用TYPO3 Docker Boilerplate+Dinghy遇502错误,未装Nginx却现Nginx报错
Hey there, let's break down why you're seeing that Nginx 502 error even though you opted for Apache in your TYPO3 container. Here's what's going on and how to fix it:
Why is Nginx showing up in the error?
Dinghy uses its own built-in Nginx instance as a reverse proxy to route local requests to your Docker containers. That's why the error references Nginx—it's the proxy layer sitting between your machine and your Apache container. A 502 means Dinghy's Nginx can't establish a successful connection to your Apache app container.
Step-by-Step Fixes
Check if your Apache container is running properly
First, confirm yourappcontainer is up and healthy:docker-compose psIf it's not in an
Upstate, start it and check logs for Apache startup issues:docker-compose up -d app docker-compose logs appLook for errors like Apache failing to bind to port 80, missing config files, or permission-related issues.
Confirm
VIRTUAL_PORTmatches Apache's listening port
Yourdocker-compose.ymlsetsVIRTUAL_PORT=80—make sure Apache inside the container is actually listening on port 80. Jump into the container to verify:docker exec -it <your-app-container-name> bash # Inside the container, run: netstat -tulpn | grep 80If Apache is listening on a different port (like 8080), update the
VIRTUAL_PORTvalue indocker-compose.ymlto match, then restart the container.Verify Dinghy's Nginx proxy configuration
Dinghy auto-generates Nginx configs based on yourVIRTUAL_HOSTsetting. Check if the config points to the right container and port:docker exec -it dinghy-nginx cat /etc/nginx/conf.d/typo3.docker.confLook for a line like
proxy_pass http://app:80;—it should reference your app service name and correct port. If the config is incorrect, restart Dinghy's Nginx container to regenerate it:docker restart dinghy-nginxTest network connectivity between Dinghy Nginx and your Apache container
Make sure the proxy can reach your app container. From the Dinghy Nginx container, try pinging and connecting to the app port:# Ping the app container (uses Docker service name) docker exec -it dinghy-nginx ping app # Test port 80 connectivity docker exec -it dinghy-nginx telnet app 80If the ping or telnet fails, your containers might not be on the same Docker network. Double-check that your
docker-compose.ymluses the default network or a network accessible to Dinghy.
Your Provided Configurations
For reference, here's the configuration you shared:
Dockerfile.development
FROM webdevops/php-apache-dev:ubuntu-14.04 ENV PROVISION_CONTEXT "development" # Deploy scripts/configurations COPY etc/ /opt/docker/etc/ RUN ln -sf /opt/docker/etc/cron/crontab /etc/cron.d/docker-boilerplate \ && chmod 0644 /opt/docker/etc/cron/crontab \ && echo >> /opt/docker/etc/cron/crontab \ && ln -sf /opt/docker/etc/php/development.ini /opt/docker/etc/php/php.ini # Configure volume/workdir WORKDIR /app/
docker-compose.yml (relevant section)
... app: build: context: . dockerfile: Dockerfile.development ... environment: - VIRTUAL_HOST=.typo3.docker - VIRTUAL_PORT=80 - POSTFIX_RELAYHOST=[mail]:1025 ...
内容的提问来源于stack exchange,提问作者Andrei Todorut

