Docker compose: Wordpress with Nginx/LetsEncrypt Proxy 502 - wordpress

my Docker compose file looks as follows:
version: '3.2'
services:
nginx-web:
image: nginx
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
container_name: ${NGINX_WEB:-nginx-web}
restart: always
ports:
- "${IP:-0.0.0.0}:${DOCKER_HTTP:-80}:80"
- "${IP:-0.0.0.0}:${DOCKER_HTTPS:-443}:443"
volumes:
- ./data/webproxy/nginx-data/conf.d:/etc/nginx/conf.d
- ./data/webproxy/nginx-data/vhost.d:/etc/nginx/vhost.d
- ./data/webproxy/nginx-data/html:/usr/share/nginx/html
- ./data/webproxy/nginx-data/certs:/etc/nginx/certs:ro
- ./data/webproxy/nginx-data/htpasswd:/etc/nginx/htpasswd:ro
logging:
driver: ${NGINX_WEB_LOG_DRIVER:-json-file}
options:
max-size: ${NGINX_WEB_LOG_MAX_SIZE:-4m}
max-file: ${NGINX_WEB_LOG_MAX_FILE:-10}
nginx-gen:
image: jwilder/docker-gen
command: -notify-sighup ${NGINX_WEB:-nginx-web} -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
container_name: ${DOCKER_GEN:-nginx-gen}
restart: always
environment:
SSL_POLICY: ${SSL_POLICY:-Mozilla-Intermediate}
volumes:
- ./data/webproxy/nginx-data/conf.d:/etc/nginx/conf.d
- ./data/webproxy/nginx-data/vhost.d:/etc/nginx/vhost.d
- ./data/webproxy/nginx-data/html:/usr/share/nginx/html
- ./data/webproxy/nginx-data/certs:/etc/nginx/certs:ro
- ./data/webproxy/nginx-data/htpasswd:/etc/nginx/htpasswd:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./data/webproxy/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
logging:
driver: ${NGINX_GEN_LOG_DRIVER:-json-file}
options:
max-size: ${NGINX_GEN_LOG_MAX_SIZE:-2m}
max-file: ${NGINX_GEN_LOG_MAX_FILE:-10}
nginx-letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: ${LETS_ENCRYPT:-nginx-letsencrypt}
restart: always
volumes:
- ./data/webproxy/nginx-data/conf.d:/etc/nginx/conf.d
- ./data/webproxy/nginx-data/vhost.d:/etc/nginx/vhost.d
- ./data/webproxy/nginx-data/html:/usr/share/nginx/html
- ./data/webproxy/nginx-data/certs:/etc/nginx/certs:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
NGINX_DOCKER_GEN_CONTAINER: ${DOCKER_GEN:-nginx-gen}
NGINX_PROXY_CONTAINER: ${NGINX_WEB:-nginx-web}
logging:
driver: ${NGINX_LETSENCRYPT_LOG_DRIVER:-json-file}
options:
max-size: ${NGINX_LETSENCRYPT_LOG_MAX_SIZE:-2m}
max-file: ${NGINX_LETSENCRYPT_LOG_MAX_FILE:-10}
database:
image: mariadb
container_name: database
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: 7ctDGg5YUwkCPkCW
entrypoint:
sh -c "/usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci"
volumes:
- ./data/database/var/lib/mysql:/var/lib/mysql
- ./data/database:/docker-entrypoint-initdb.d
networks:
- backend-network
auth:
image: jboss/keycloak
container_name: auth
restart: always
ports:
- 8443:8443
environment:
DB_VENDOR: mariadb
DB_ADDR: database
DB_DATABASE: users
DB_USER: keycloak
DB_PASSWORD: jk2zKvGkJXBsrNMV
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: M+f{7_Hc>&Z.;6W6
JDBC_PARAMS: "ssl=false"
PROXY_ADDRESS_FORWARDING: 'true'
volumes:
- ./data/webproxy/nginx-data/certs/pm-app.de/fullchain.pem:/etc/x509/https/tls.crt
- ./data/webproxy/nginx-data/certs/pm-app.de/key.pem:/etc/x509/https/tls.key
depends_on:
- database
networks:
- backend-network
# fileupload:
# image: openjdk:14-jdk-alpine
# container_name: fileupload
# ports:
# - 8082:8082
# depends_on:
# - database
# - auth
# volumes:
# - ./fileupload-server.jar:/fileupload-server.jar
# command: ["java", "-jar", "fileupload-server.jar"]
# networks:
# - backend-network
# websocket:
# image: openjdk:14-jdk-alpine
# container_name: websocket
# ports:
# - 8083:8083
# depends_on:
# - database
# - auth
# volumes:
# - ./websocket-server.jar:/websocket-server.jar
# command: ["java", "-jar", "websocket-server.jar"]
# networks:
# - backend-network
# resource:
# image: openjdk:14-jdk-alpine
# container_name: resource
# ports:
# - 8081:8081
# depends_on:
# - fileupload
# - websocket
# - auth
# volumes:
# - ./backend/resource-server.jar:/resource-server.jar
# command: ["java", "-jar", "resource-server.jar"]
# networks:
# - backend-network
# frontend:
# image: nginx:alpine
# container_name: frontend
# ports:
# - 4200:4200
# depends_on:
# - resource
# volumes:
# - ./frontend/nginx.conf:/etc/nginx/nginx.conf
# - ./frontend/dist/propositum-frontend:/usr/share/nginx/html
# networks:
# - frontend-network
wordpress:
image: wordpress:latest
container_name: wordpress
restart: always
environment:
WORDPRESS_DB_HOST: database
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: QKJFUfZbv7jMB5ba
WORDPRESS_TABLE_PREFIX: wp_
VIRTUAL_HOST: domain.de
LETSENCRYPT_HOST: domain.de
LETSENCRYPT_EMAIL: info#domain.de
depends_on:
- database
volumes:
- wordpress_data:/var/www/html
networks:
- backend-network
- webproxy
ftp:
image: stilliard/pure-ftpd:hardened-latest
container_name: ftp
deploy:
replicas: 1
restart_policy:
condition: on-failure
environment:
PUBLICHOST: Ip
FTP_USER_NAME: "ftp"
FTP_USER_PASS: "+/x~qy//vf(S6L:<"
FTP_USER_HOME: "/var/www/html"
FTP_USER_UID: 33
FTP_USER_GID: 33
volumes:
- wordpress_data:/var/www/html
#- ./data/ftp:/etc/ssl/private
ports:
- 21:21
- 30000:30000
volumes:
database_data:
wordpress_data:
networks:
backend-network:
frontend-network:
webproxy:
external:
name: "webproxy"
But when I try to access the wordpress instance over the browser, to start the installation process. And only got an 502 bad gateway.
The interesting thing is that it already worked before, the only thing what I've changed was, that I am moved all config files and directories, which was before in a seperate folder, to the datadata folder (./data/webproxy) and cut out the services from the old docker compose file to an existing one and also edited file paths from the mapped volumes. Hopefully this are enough details to help me, otherwise let me know when you need more information.
So far,
Daniel

Related

Can't get a Docker image of both PHPMyAdmin and MariaDB to work together

I'm using Docker and a docker-compose.yml file to pop up a WordPress site using Bitnami and MariaDB. With just these two services alone, everything is fine, but I have no way to view/access the data in MariaDB. To solve the issue, I added the PHPMyAdmin service to the compose file since I'm familiar with that service. However, one of two problems happen: either all three services stay up and work fine and I can't login to PHPMyAdmin, or MariaDB shuts down every time immediately after starting up and the whole image doesn't work.
This configuration keeps the image up, but doesn't let me login to PHPMyAdmin...
services:
# Database
mariadb:
image: docker.io/bitnami/mariadb:latest
container_name: test_mariadb_database
volumes:
- 'mariadb_data:/bitnami/mariadb'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=test_bn_wp
- MARIADB_DATABASE=test_bitnami_wordpress
networks:
- test_bn
# phpmyadmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: test_pma
links:
- mariadb
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80
# Wordpress
wordpress:
image: docker.io/bitnami/wordpress:latest
ports:
- '80:8080'
- '443:8443'
restart: always
container_name: test_bitnami_wordpress
volumes: ['./docroot:/bitnami/wordpress']
depends_on:
- mariadb
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- WORDPRESS_DATABASE_HOST=mariadb
- WORDPRESS_DATABASE_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=test_bn_wp
- WORDPRESS_DATABASE_NAME=test_bitnami_wordpress
networks:
- test_bn
networks:
test_bn:
volumes:
mariadb_data:
driver: local
wordpress_data:
driver: local
So I change to this configuration, thinking that the password can't be blank, but it causes MariaDB to shut down immediately after starting up, thus rendering the whole image useless...
services:
# Database
mariadb:
image: docker.io/bitnami/mariadb:latest
container_name: test_mariadb_database
volumes:
- 'mariadb_data:/bitnami/mariadb'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=no
- MARIADB_USER=test_bn_wp
- MARIADB_PASSWORD=test_password
- MARIADB_ROOT_PASSWORD=test_password
- MARIADB_DATABASE=test_bitnami_wordpress
networks:
- test_bn
# phpmyadmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: test_pma
links:
- mariadb
environment:
PMA_HOST: mariadb
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80
# Wordpress
wordpress:
image: docker.io/bitnami/wordpress:latest
ports:
- '80:8080'
- '443:8443'
restart: always
container_name: test_bitnami_wordpress
volumes: ['./docroot:/bitnami/wordpress']
depends_on:
- mariadb
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- WORDPRESS_DATABASE_HOST=mariadb
- WORDPRESS_DATABASE_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=test_bn_wp
- WORDPRESS_DATABASE_NAME=test_bitnami_wordpress
networks:
- test_bn
networks:
test_bn:
volumes:
mariadb_data:
driver: local
wordpress_data:
driver: local
Edit - This is the error I get when trying to login to PHPMyAdmin with the first config.

Docker nginx container with wordpress uploads folder on volume, can't upload files due to permission denied

I have an nginx container running wordpress (using docker compose) and the uploads folder assigned to a volume:
vipirs-uploads:/usr/share/nginx/html/website/wp-content/uploads
I can't upload files:
Unable to create directory wp-content/uploads/2022/05. Is its parent
directory writable by the server?
So the actual uploads folder doesn't exist on the host machine.
Normally i would simply set the correct permissions but in this case i'm not sure how i would go about this. As a test i tried setting chmod to 777 on the folder inside the container but that didn't work.
My docker-compose.yml:
version: '3.7'
services:
rhino-php:
platform: linux/amd64
build:
context: ./docker
dockerfile: Dockerfile-php7.4
image: rhino-php
container_name: rhino-php
volumes:
- ./Vipirs-Website:/usr/share/nginx/html
ports:
- 9000
networks:
- vipirs-net
rhino-proxy:
platform: linux/amd64
image: nginx:alpine
container_name: rhino-proxy
depends_on:
- vipirs-website
volumes:
- ./docker/nginx/proxy-live.conf:/etc/nginx/nginx.conf
- /usr/local/share/sites/vipirs.com/docker/ssl/live:/usr/local/etc/ssl/certs
ports:
- 80:80
- 443:443
networks:
- vipirs-net
vipirs-website:
platform: linux/amd64
image: nginx
container_name: vipirs-website
depends_on:
- rhino-php
- vipirs-website-database
volumes:
- ./docker/nginx/site-live.conf:/etc/nginx/conf.d/default.conf
- ./Vipirs-Website:/usr/share/nginx/html
- ./Vipirs-Website/logs/wp-debug.log:/usr/share/nginx/html/website/wp-content/debug.log
- vipirs-uploads:/usr/share/nginx/html/website/wp-content/uploads
- /usr/local/share/sites/vipirs.com/docker/ssl/live:/usr/local/etc/ssl/certs
ports:
- 80
- 443
links:
- rhino-php
networks:
- vipirs-net
vipirs-website-database:
platform: linux/amd64
image: mysql:5.7
container_name: vipirs-db
environment:
MYSQL_ROOT_PASSWORD: vipirs
MYSQL_DATABASE: vipirs
MYSQL_USER: vipirs
MYSQL_PASSWORD: vipirs
volumes:
- ./Vipirs-Website/db:/usr/share/db
- vipirs-db:/var/lib/mysql
restart: always
ports:
- 3306
networks:
- vipirs-net
networks:
vipirs-net:
volumes:
vipirs-uploads:
vipirs-db:

Docker compose in Debian bullseye

I am using docker-compose, this is my environment
Linux Debian 11 (bullseye)
docker-compose v 1.29.2
ufw v 0.36
this is my daemon.json in /etc/docker
{
"iptables": false,
"dns": [
"8.8.8.8",
"8.8.4.4",
"172.17.0.1"
]
}
This is my docker-compose.yml
version: "3.8"
services:
pgadmin4:
#
# This container runs as user 5050 and group 5050
#
container_name: "pgadmin4-connexx"
restart: unless-stopped
image: "dpage/pgadmin4:latest"
networks:
- leitfeld-net
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
#
# This folder must have owner 5050 and group 5050
# chown 5050:5050 /usr/local/pgadmin4
#
- /usr/local/pgadmin4:/var/lib/pgadmin
- /etc/ssl/certs/pgadmin4cert.pem:/certs/server.cert
- /etc/ssl/private/pgadmin4key.pem:/certs/server.key
ports:
- "5050:443"
environment:
PGADMIN_DEFAULT_EMAIL: "xxxxxxx"
PGADMIN_DEFAULT_PASSWORD: "xxxxxxxx"
PGADMIN_ENABLE_TLS: "True"
php:
container_name: "php-connexx"
restart: unless-stopped
image: "php:7.2-fpm"
networks:
- leitfeld-net
volumes:
- /var/www/html:/var/www/html
natsd:
container_name: "nats-connexx"
restart: unless-stopped
image: "nats:2.0.2"
networks:
- leitfeld-net
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- /usr/local/etc/nats.conf:/etc/nats.conf
- /var/log/:/var/log
ports:
- "4222:4222"
- "8222:8223"
command: "-c /etc/nats.conf"
mqttd:
container_name: "mqtt-connexx"
restart: unless-stopped
image: "eclipse-mosquitto:latest"
networks:
- leitfeld-net
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- /usr/local/mqttd:/mosquitto
- /usr/local/mqttd/data:/mosquitto/data
- /var/log/mqtt:/mosquitto/log
ports:
- "12345:8883"
certbot:
container_name: "certbot-connexx"
restart: unless-stopped
image: "certbot/certbot"
networks:
- leitfeld-net
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- /usr/local/etc/letsencrypt:/etc/letsencrypt
- /var/log/letsencrypt:/var/log/letsencrypt
- /var/www/certbot:/var/www/certbot
- /usr/local/sbin/renewCertificates.bash:/renewCertificates.bash
entrypoint: "/renewCertificates.bash"
nginx:
container_name: "nginx-connexx"
restart: unless-stopped
image: "nginx:latest"
networks:
- leitfeld-net
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- /usr/local/etc/nginx/nginx.conf:/etc/nginx/nginx.conf
- /usr/local/etc/nginx/sites-available:/etc/nginx/sites-available
- /usr/local/etc/nginx/sites-enabled:/etc/nginx/sites-enabled
- /usr/local/etc/letsencrypt/:/etc/letsencrypt
- /var/log/nginx/:/var/log/nginx
- /var/www/html:/var/www/html
- /var/www/certbot:/var/www/certbot
ports:
- "80:80/tcp"
- "443:443/tcp"
networks:
leitfeld-net:
driver: bridge
The problem I have is that if I try to do a telnet xxx.xxx.xxx 5050 from external server I have the connection "hanging" and I cannot see the link active by doing netstat -a | grep 5050 but just
tcp 0 0 0.0.0.0:5050 0.0.0.0:* LISTEN
tcp6 0 0 [::]:5050 [::]:* LISTEN
This happens also disabling ufw (# ufw disable).
Now it works but I do not know why, by doing a reboot of the server I still have the same problem.
Then, if I change the daemon.json and put "iptables": false, I restart docker service and I connect to a docker docker exec -it --user root pgadmin4-connexx /bin/sh I am not able to ping anything; for instance ping 8.8.8.8 does NOT respond.

How to connect wordpress install and cli docker

I am having great trouble with this, Trying to add wp cli to my wordpress installation with docker-compose but cant get it done as im getting an error when trying to connect the two in docker compose - IM getting an error about duplicate volumes.
Can you see what this is?
version: '3.3'
services:
db:
image: mysql
restart: always
volumes:
- mysql_data:/var/lib/mysql
- ./database/init:/docker-entrypoint-initdb.d/:ro
environment:
- MYSQL_ROOT_PASSWORD=admin
- MYSQL_DATABASE=mydb_assdf
- MYSQL_USER=admin
- MYSQL_PASSWORD=admin
security_opt:
- seccomp:unconfined
wordpress:
image: wordpress
depends_on:
- db
- phpmyadmin
ports:
- '8000:80'
restart: always
volumes:
- ./wordpress:/var/www/html
- wp_data:/var/www/html
environment:
- WORDPRESS_DB_HOST=db:3306
- WORDPRESS_DB_USER=admin
- WORDPRESS_DB_PASSWORD=admin
- WORDPRESS_DB_NAME=mydb_assdf
- WORDPRESS_TABLE_PREFIX=adsf_
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
- PMA_HOST=db
- MYSQL_ROOT_PASSWORD=admin
wpcli:
image: wordpress:cli
restart: always
depends_on:
- wordpress
volumes:
- wp_data:/var/www/html
- ./default/:/var/www/html/wp-content
ports:
- '1111:80'
volumes:
mysql_data:
driver: local
wp_data:
driver: local

Setting up docker Multisite configuration (VIPGo Environment)

I am trying to create a multisite docker configuration and I am not sure how to proceed with the existing docker-compose.yml that I use. I have already it up so that I can spin up as many sites as I want using a network. Here is the shared docker-compose.yml for reference.
version: "3.3"
services:
photon:
image: "chriszarate/photon:latest"
mysql:
image: "mariadb:10.2"
container_name: "mysql-database"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: "wordpress"
MYSQL_ROOT_PASSWORD: ""
ports:
- "3306:3306"
restart: always
volumes:
- type: volume
source: dbdata
target: "/var/lib/mysql"
volume:
nocopy: true
#- "./sql:/docker-entrypoint-initdb.d"
adminer:
image: adminer
restart: always
ports:
- 8080:8080
proxy:
image: "jwilder/nginx-proxy:alpine"
container_name: "proxy"
environment:
HSTS: "off"
HTTPS_METHOD: "nohttps"
ports:
- "80:80"
- "443:443"
volumes:
- "//var/run/docker.sock:/tmp/docker.sock:ro"
- "./certs/self-signed:/etc/nginx/certs:ro"
- "./conf/nginx-proxy.conf:/etc/nginx/conf.d/proxy.conf:ro"
networks:
default:
external:
name: shared
volumes:
dbdata: {}
And here is the one that I use for sites.
version: "3.3"
services:
wordpress:
container_name: "wp"
image: "wordpress:${WP_VERSION:-4.9.7}-php${PHP_VERSION:-7.2}-apache"
environment:
VIRTUAL_HOST: "${DOCKER_DEV_DOMAIN:-project.test}"
WORDPRESS_DB_HOST: "mysql"
WORDPRESS_DB_NAME: "wordpress"
WORDPRESS_DB_PASSWORD: ""
WORDPRESS_DB_USER: "root"
external_links:
- mysql
volumes:
- "wp:/var/www/html:rw"
- "./certs/ca-root/ca.crt:/tmp/certs/root.crt:ro"
- "./conf/php-local.ini:/usr/local/etc/php/conf.d/local.ini:ro"
- "./conf/wp-local-config.php:/usr/local/etc/php/autoprepend.php:ro"
- "./src/vip-go-mu-plugins:/var/www/html/wp-content/mu-plugins"
- "./src/site1/client-mu-plugins:/var/www/html/wp-content/client-mu-plugins"
- "./src/site1/images:/var/www/html/wp-content/images"
- "./src/site1/languages:/var/www/html/wp-content/languages"
- "./src/site1/plugins:/var/www/html/wp-content/plugins"
- "./src/site1/private:/var/www/html/wp-content/private"
- "./src/site1/themes:/var/www/html/wp-content/themes"
- "./src/site1/vip-config:/var/www/html/wp-content/vip-config"
wp-cli:
container_name: "wp-cli"
image: "wordpress:cli-php${PHP_VERSION:-7.2}"
environment:
- APACHE_RUN_USER="www-data"
- APACHE_RUN_GROUP="www-data"
external_links:
- mysql
volumes:
- "wp:/var/www/html:rw"
- "./bin/install-wp.sh:/usr/local/bin/install-wp:ro"
- "./conf/php-local.ini:/usr/local/etc/php/conf.d/local.ini:ro"
- "./conf/wp-local-config.php:/usr/local/etc/php/autoprepend.php:ro"
- "./src/vip-go-mu-plugins:/var/www/html/wp-content/mu-plugins"
- "./src/site1/client-mu-plugins:/var/www/html/wp-content/client-mu-plugins"
- "./src/site1/images:/var/www/html/wp-content/images"
- "./src/site1/languages:/var/www/html/wp-content/languages"
- "./src/site1/plugins:/var/www/html/wp-content/plugins"
- "./src/site1/private:/var/www/html/wp-content/private"
- "./src/site1/themes:/var/www/html/wp-content/themes"
- "./src/site1/vip-config:/var/www/html/wp-content/vip-config"
networks:
default:
external:
name: shared
volumes:
wp: {}
This setup works fine for one site (any other sites I spin up when I make copies of the folder) and it replicates the environment that VIP Go has. But I am not sure what changes will be needed to make this work with multisite environment as each site will have a different folder when docker is spun up.
Any ideas?
TIA
Note: multisites will be different sites and not subdomains when it's set up in production so I need to keep it that way and not set up subdomains

Resources