Wordpress and nginx on docker

Posted March 9, 2020 2.7k views
NginxWordPressDockerUbuntu 18.04

Okay, so I got wordpress and nginx running on docker. Everything works fine. Except for some reason (probably me being stupid) I can’t open my site without adding the port in the url. so
I want just
I don’t understand. I’m getting frustrated.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hello, @emanuelrahn

What you can do in order to achieve this is to set a Nginx reverse proxy. You can do this by editing the nginx configuration file:

open/create the config file /etc/nginx/sites-available/

You should have the following content:

server {
  listen 80;

  location / {
   proxy_pass http://localhost:9000;

You need to create the symlink for the file and make it available in the sites-enabled directory as well:

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Then check the Nginx configuration files for any syntax errors:

sudo nginx -t

If you see that the Syntax is Okay, then restart Nginx. If you get some syntax errors, check the exact row/line that was reported in the message and sort this out before you continue further.

sudo systemctl restart nginx

You can also see this amazing video tutorial on how to do this on a DigitalOcean droplet:

Hope this helps!


  • Okay thank you for your reply.
    I was stupid tho. I forgot to update my iptables.
    just did ufw disable and it worked

    • Hello, @emanuelrahn

      I’m glad you’ve sorted this. If there is anything else, feel free to ask.


    • IPtables and Docker is both rather bloated, better just to use basic LEMP stack I think for WordPress.

      • Hello, @aalamsa

        Running WordPress typically involves installing a LAMP (Linux, Apache, MySQL, and PHP) or LEMP (Linux, Nginx, MySQL, and PHP) stack, which can be time-consuming. However, by using tools like Docker and Docker Compose, you can simplify the process of setting up your preferred stack and installing WordPress. Instead of installing individual components by hand, you can use images, which standardize things like libraries, configuration files, and environment variables, and run these images in containers, isolated processes that run on a shared operating system. Additionally, by using Compose, you can coordinate multiple containers — for example, an application and database — to communicate with one another.

        Feel free to share your experience with us.