I use Docker-compose to develop the WordPress website together with Mysql and PHPMyAdmin.
Also, use Portainer to monitor them, showing the health icon, and I can access it by typing the IP address 192.168.188.80:3001, and I can curl the page from port 3001.
I try to assign the domain name for the different containers, there will have a couple of WordPress websites and I plan to host them on ports 3001, 3002, 3003…
I enable the conf file in Nginx and the conf file like
server {
listen 80;
server_name forktruck.bcsystems.nz;
location / {
proxy_pass http://0.0.0.0:3001;
}
}
The yml file is here
version: '3.8'
volumes:
wp-forktruck-data:
networks:
wp-forktruck-network:
services:
db:
image: mysql:latest
volumes:
- ./wp-forktruck-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: wordpress-forktruck
MYSQL_USER: wp-forktruck
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- 3201:3306
healthcheck:
test: curl --fail http://localhost || exit 1
interval: 300s
start_period: 5s
timeout: 10s
restart: always
networks:
- wp-forktruck-network
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
environment:
PMA_HOST: db
MYSQL_USER: wp-forktruck
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
ports:
- 3101:80
healthcheck:
test: curl --fail http://localhost || exit 1
interval: 300s
start_period: 5s
timeout: 10s
networks:
- wp-forktruck-network
wordpress:
depends_on:
- db
image: wordpress
ports:
- 3001:80
healthcheck:
test: curl --fail http://localhost || exit 1
interval: 300s
start_period: 5s
timeout: 10s
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wp-forktruck
WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
WORDPRESS_DB_NAME: wordpress-forktruck
volumes:
- ./forktruck:/var/www/
container_name: wp-forktruck
networks:
- wp-forktruck-network
but something wrong and the domain name got 520 error.
2
Answers
You are using Cloudflare? What is your Cloudflare DNS configs. Are you sure that the domain is pointing to public address of 192.168.188.80 (as 192.168.188.80 is private IP address and it’s accessible only on your internal network but not the internet).
If you don’t know your public IP address, run
curl ipinfo.io
on the 192.168.188.80 server to get your public IP address. And then update your Cloudflare DNS config of domainforktruck.bcsystems.nz
to that address.Note: it’s easy and worked only if you are using static IP address. If not, please consider https://ngrok.com/ instead of Cloudflare.
you need to add the redirect option in nginx
And should work, good luck