1

I am trying to run a WordPress app inside of a docker container on Ubuntu VPS using Nginx-Proxy.

First I run the nginx-proxy server using the following command

docker run -d \
-p 80:80 \
-p 443:443 \
--name proxy_server \
--net nginx-proxy-network \
-v /etc/certificates:/etc/nginx/certs \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
jwilder/nginx-proxy

Then I run the mysql database server using the following command

docker run -d \
--name mysql_db \
--net nginx-proxy-network \
-e MYSQL_DATABASE=db1 -e \
MYSQL_USER=db1 -e \
MYSQL_PASSWORD=db1 -e \
MYSQL_ROOT_PASSWORD=db12 \
-v mysql_server_data:/var/lib/mysql \
mysql:latest

I am able to verify that MySql server is running by connecting to it using the following command

root:~# docker exec -it mysql_db /bin/bash
root@dd7643384f76:/# mysql -h localhost -u root -p
mysql> show databases;

Now that nginx-proxy and mysql_db images are running, I want to proxy the WordPress image on the usa.mydomain.com. To do that, I run the following command

docker run -d \
--name wordpress \
--expose 80 \
--net nginx-proxy-network \
-e DEFAULT_HOST=usa.mydomain.com \
-e WORDPRESS_DB_HOST=mysql_db:3306 \
-e WORDPRESS_DB_NAME=db1 \
-e WORDPRESS_DB_USER=db1 \
-e WORDPRESS_DB_PASSWORD=db1 \
-v wordpress:/var/www/html \
wordpress:latest

I can see all 3 container running by executing docker ps -a

enter image description here

However, when I browser http://usa.mydomain.com I get HTTP error 503

503 Service Temporarily Unavailable nginx/1.17.5

I validated that usa.mydomain.com is pointing to the server's IP address by doing the following using the command line my my machine.

ipconfig /flushdns
ping usa.mydomain.com

Even when I try to browse my server's ip address I get the same 503 error.

What could be causing this issue?

Jay
  • 1,168
  • 13
  • 41
  • nginx will not proxy automatically. How does your config look like? I don't see you mount one, only a cert. And for dubious reasons you mount the docker socket. That's considered a security risk. – The Fool Oct 14 '20 at 23:06
  • What config file are you asking about? I thought the whole idea behind nginx-proxy that it does this work for you automatically. I am just following the documentation where they require `/var/run/docker.sock:/tmp/docker.sock:ro`. – Jay Oct 14 '20 at 23:13
  • I recommend dropping that documentation, whatever you are reading. You should not need to mount the socket to set up a proxy and a WordPress container. I am talking about the [nginx.conf](https://www.nginx.com/resources/wiki/start/topics/examples/full/) – The Fool Oct 14 '20 at 23:22
  • 1
    @TheFool I am reading https://github.com/nginx-proxy/nginx-proxy and https://blog.ssdnodes.com/blog/host-multiple-websites-docker-nginx/ I don't have a `nging.conf`, its my understanding the `jwilder/nginx-proxy` image does auto configure that apps using the host. – Jay Oct 14 '20 at 23:25
  • I see, I was not aware of this jwilder/nginx-proxy. This is mounting the socket so it can use the socket to start a sibling container running docker-gen. And docker-gen is actually genrating the nginx.conf I was looking for. Its a fairly complex setup and it may be overkill. I can show you how to do it more easy. From the ground ups. If you have chat or something. – The Fool Oct 14 '20 at 23:35
  • DM me on twitter I don't know how to open the chat but I need to sleep now anyways. I can connect after work tomorrow. Handle is @codingsafari – The Fool Oct 14 '20 at 23:48

0 Answers0