I'm launching a Docker container for WordPress following this tutorial. I'm running this on a machine that is at my desk, I have complete access. It is running Ubuntu 20.04.

Here is my docker-compose.yml for reference.

version: '3.3'

     image: mysql:5.7
       - db_data:/var/lib/mysql
     restart: always
       MYSQL_ROOT_PASSWORD: rootpassword
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: dbpassword

       - db
     image: wordpress:latest
       - "12130:80"
     restart: always
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: dbpassword
       WORDPRESS_DB_NAME: wordpress
    db_data: {}

(Passwords replaced)

When I run docker-compose up -d, the container comes up, the server is available at, and I can configure and install WordPress. Everything works fine from the machine hosting the application.

When I try to access the site from a different device, the blog loads, but there are no styles. I expect that this is because the "Site Address" is configured as, so when the browser tries to fetch the stylesheet, it's going there, which 404s.

I believe the solution here is to configure nginx to give the application a public address and change the "Site Address" and "WordPress Address" to that address. Once I do that, the entire service is completely inaccessible by any means. I have to destroy the data with docker-compose down --volumes and install from scratch.

For reference, here is my complete /etc/nginx/conf.d/default.conf, I stripped everything else out. I also stopped all of my other web services, so just WordPress is running.

ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;

server {
    listen 443 ssl;
    server_name sub.mydomain.org;

    location / {

If I try to access https://sub.mydomain.org using Firefox, it redirects me to (no port) and gives me the standard "Unable to connect" page. If I curl https://sub.mydomain.org, it exits with no output and no errors. I get the same error using and localhost:12130 directly, they both just redirect me to, no port, and fail to connect or return empty.

At this point, if I wait a few minutes, accessing or https://sub.mydomain.org in Firefox causes the page to infinitely reload. This is repeatable, I have done this process several times in making sure I have my information straight. For the first few minutes it just redirects to and dies, then it starts infinitely reloading without me changing any config files or restarting any services.

One final note. If I turn on nginx before changing the "Site Address" setting, I can access the server from outside my network just fine, but as before, the styles don't load. So nginx is doing something. And it's been working fine for the other servers I'm hosting.

What's going on here?

Why can I not access the server after I change "Site Address" and "WordPress Address"?

  • Am I going down the complete wrong path by trying to modify the "Site Address" and "WordPress Address" settings?
  • If I should modify those, why is the server behaving like this?
    • Is my nginx configuration wrong?
    • Is my WordPress configuration wrong?
    • Is something else wrong?
  • Or is it something completely different?

I'm very new to self hosting, I apologize if there is an an obvious solution that I'm not seeing. Thank you for your patience.

  • You can't use to access the site externally. – AlexD Feb 8 at 11:24
  • @AlexD Yes, I understand that. I never tried to do that. I only made one reference to connecting externally, which did work because I used the server's LAN address. That's the not problem. The problem is that after setting the "Site Address", I cannot access it all, locally or externally. – TechnoSam Feb 8 at 14:35
  • You say above that you configured your "Site Address" as "". This means that WordPress will automatically redirect you to that address, and it won't work if you attempting to access the site externally. Also, you didn't specify what is the address sub.mydomain.org resolves to. If it is then you have the same problem. – AlexD Feb 8 at 15:59
  • No, I didn't say that. I said that it defaults to localhost. I specifically say that I changed it to sub.mydomain.org. And my DNS is set up correctly, I've tested that. It works for other applications, and I even specifically mentioned that I can access the site outside my network before changing "Site Address" externally, using the domain name. I appreciate your time, but I'm quite certain the problem lies elsewhere. Is there anything else you would check to figure out why the site becomes inaccessible after changing the Site Address? – TechnoSam Feb 8 at 17:56

It turns out that I needed to set some headers in my nginx config. This post helped me discover that.

Now my config looks like this.

server {
    listen 443 ssl;
    server_name sub.domain.org;

    location / {
        proxy_set_header    Host                $host;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto   $scheme;
        proxy_set_header    Accept-Encoding     "";
        proxy_set_header    Proxy               "";

After setting the "Site Address" and "WordPress Address", everything seems to be working.

I would like to do some more research to understand exactly what's happening here and why it's necessary. If anyone wants to explain in the comments I'd be grateful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.