I am trying to make a compose file that I can use to host WordPress sites behind Traefik. I have it mostly working however I can not get the Nginx Container to connect to the wordpress:fpm-apline container. They both start and fpm says its listening. Nginx gets an error connection refused when trying to connect. My files as I have them now:
version: '3.6'
services:
wordpress:
image: wordpress:fpm-alpine
volumes:
- ./www:/var/www/html
environment:
- WORDPRESS_DB_NAME=wordpress
- WORDPRESS_TABLE_PREFIX=wp_
- WORDPRESS_DB_HOST=mysql
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=password125@#
depends_on:
- mysql
restart: always
# networks:
# - internal
mysql:
image: mariadb:latest
volumes:
- ./mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=password100@#
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=password125@#
- MYSQL_DATABASE=wordpress
restart: always
# networks:
# - internal
nginx:
image: nginx:latest
volumes:
- ./config/nginx:/etc/nginx/conf.d
- ./logs/nginx:/var/log/nginx
- ./www:/var/www/html
depends_on:
- wordpress
labels:
- "traefik.enable=TRUE"
- "traefik.backend=${URL}"
- "traefik.frontend.rule=Host:${URL}"
- "traefik.docker.network=traefik_proxy"
- "traefik.port=80"
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.frontend.headers.STSSeconds=0"
- "traefik.frontend.headers.browserXSSFilter=true"
- "traefik.frontend.headers.contentTypeNosniff=true"
- "traefik.frontend.headers.forceSTSHeader=false"
- "traefik.frontend.headers.SSLHost=${URL}"
- "traefik.frontend.headers.STSIncludeSubdomains=false"
- "traefik.frontend.headers.STSPreload=false"
- "traefik.frontend.headers.frameDeny=true"
restart: always
networks:
- traefik_proxy
# - internal
networks:
traefik_proxy:
external:
name: traefik_proxy
# internal:
Nginx uses wordpress:9000
to connect to the php container running on the wordpress container.
I tried specifically assigning each one to the default
network as well as creating an internal
network. I feel like there is something really stupid I am missing. One of the questions I had and could not find an exact answer to in the docs is when I use the networks
option to set nxinx to the external traefik_proxy
network, will it still be connected to the default network also? Or do I need to specify default also?