problems when setting up an application in a different docker-compose.yml
Inkimar opened this issue · comments
Ing Erl commented
Hi,
I am having problem when setting up the service as-is, it is not finding my wordpress instance running on a specifik URL (i.e example.org) / not redirecting to the URL.
The setting is this.
- running the init-letsencrypt.sh after editing it.
- home/user/repository/proxy-docker/docker-compose.yml
version: '3.7'
services:
nginx:
image: nginx:1.15-alpine
container_name: nginx_1
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./data/nginx:/etc/nginx/conf.d
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
certbot:
image: certbot/certbot
restart: unless-stopped
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
- spinning up this
docker-compose up -d
gives me the network -> proxy-docker_default - Running wordpress from this site -> https://github.com/chrisbmatthews/wordpress-docker-compose.git
- home/user/repository/wordpress-docker-compose/docker-compose.yml
version: '3.7'
services:
wp:
image: wordpress:5.8.1-apache
container_name: wordpress
restart: unless-stopped
volumes:
- ./config/php.conf.ini:/usr/local/etc/php/conf.d/conf.ini
- ./wp-app:/var/www/html
environment:
VIRTUAL_HOST: example.org #same as in the init-letsencrypt
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: "${DB_NAME}"
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: "${DB_ROOT_PASSWORD}"
depends_on:
- db
db:
image: mysql:5.7
ports:
- ${IP}:3306:3306
command: [
'--default_authentication_plugin=mysql_native_password',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci'
]
volumes:
- ./wp-data:/docker-entrypoint-initdb.d
- db_data:/var/lib/mysql
environment:
MYSQL_DATABASE: "${DB_NAME}"
MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
volumes:
db_data:
networks:
default:
external:
name: proxy-docker_default # attaching to the network that nginx/certbot is running
- inspecting the -network,
docker inspect proxy-docker_default
, gives (a subset of the output)
"Containers": {
"2f266b1a36207486fbe127ae7802fcd21518892a883671292c40867f1c2b0bd6": {
"Name": "nginx_1",
"EndpointID": "a8de3d8f5fcead1cb090fb52c256f7b4a69d7646d0407f94372faccefe1af900",
"MacAddress": "02:42:ac:1a:00:02",
"IPv4Address": "172.26.0.2/16",
"IPv6Address": ""
},
"66cc035957e0325905e7c093ddadee41816154e3cb729b273e766015c58ae699": {
"Name": "wordpress",
"EndpointID": "ecb847e0b282cc4a8679ee31c0df320d40a448e345ae244873fc06db06a7512e",
"MacAddress": "02:42:ac:1a:00:05",
"IPv4Address": "172.26.0.5/16",
"IPv6Address": ""
},
"93d6aed6ddc30a4cad2231c9cd0b2cc944dbdf07524ed6d25d86120f1ba5e5d1": {
"Name": "proxy-docker_certbot_1",
"EndpointID": "0aa79a3876dc1c556b1d3f58eb27dd733ecd6b8ba855c08de9976da06e550feb",
"MacAddress": "02:42:ac:1a:00:03",
"IPv4Address": "172.26.0.3/16",
"IPv6Address": ""
},
"c623641458fd1274948b3e3c84e007ab60f9292d1498722561ae31929a72e7cc": {
"Name": "wordpress-docker-compose_db_1",
"EndpointID": "795e0ce8131a21ee917e3a6bc5faea5c2583272e4e4420b9e4e067b59f5a8a16",
"MacAddress": "02:42:ac:1a:00:04",
"IPv4Address": "172.26.0.4/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "proxy-docker",
"com.docker.compose.version": "1.27.4"
}
}
- accessing wordpress by browser gives
The page isn’t redirecting properly
This problem can sometimes be caused by disabling or refusing to accept cookies.
Looking at the logs for nginx, I can see an incoming request but I cannot se anything in the wordpress log ....
Replacing the nginx/certbot proxy with the one below (no app.conf) then the forwarding from nginx to wordpress works (VIRTUAL_HOST: example.org
)
version: '3.7'
services:
nginx-jwilder:
image: jwilder/nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
Could I make this work by editing the data/nginx/app.conf
adding som config ?
Best, i
Cosmic Oppai commented
can you show the nginx configuration file.