WordPress in Docker Spits 502 Error after Nginx
-
I’m trying to dockerise all of my WordPress instances as I now have multiple sites on the same server, and want transfers to go smoothly etc. My plan is to have each site with its on DB in Docker containers, and then reverse proxy them using Nginx.
So, I’m running a WordPress and MariaDB instance in Docker on an Ubuntu Server VM inside VirtualBox on a Windows 10 machine. Then installed on the bare Ubuntu Server VM (not a Docker container), is an instance of Nginx. I want my Nginx instance to forward requests from “https://test.domain.com/”, to https://127.0.0.1:8181/ (the WordPress Docker instance).
I can access the install page for the WordPress instance via 192.168.0.30:8181, so the webserver is running, however test.domain.com gives a 502 error. I’m thinking I need to trust the proxy from within WordPress? Unsure of how to do that though.
No online article seems to be able to help ??
Thanks in advance!
docker-compose.yml:
services: wordpress: image: wordpress links: - mariadb:mysql environment: - WORDPRESS_DB_PASSWORD=REDACTED - WORDPRESS_DB_USER=REDACTED ports: - "192.168.0.30:8181:80" volumes: - ./html:/var/www/html mariadb: image: mariadb environment: - MYSQL_ROOT_PASSWORD=REDACTED - MYSQL_DATABASE=wordpress volumes: - ./database:/var/lib/mysql
Nginx Config:
server { listen 8080; server_name test.REDACTED.com; return 301 https://$host$request_uri; } server { listen 443 ssl http2; server_name test.REDACTED.com; location / { proxy_pass https://127.0.0.1:8181; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } # SSL parameters ssl_certificate /etc/ssl/www.REDACTED.com.crt; ssl_certificate_key /etc/ssl/www.REDACTED.com.key; # log files access_log /var/log/nginx/test.REDACTED.com.access.log; error_log /var/log/nginx/test.REDACTED.com.error.log; }
The page I need help with: [log in to see the link]
- The topic ‘WordPress in Docker Spits 502 Error after Nginx’ is closed to new replies.