NGINX reverse proxy to Apache docker container

September 4, 2018 9.9k views
Nginx Apache Docker Ubuntu 16.04

I’m trying to host several websites on my droplet. I’m to do that, I’m using NGINX (not container) as reverse proxy to Dockerized apps. One such app I’m using is the dockerized Mediawiki set to run on

Mediawiki container is based on php7.2-apache.

Nginx configuration :

server {

        listen 443 ssl;
        index index.php;


        ssl_stapling on;
        ssl_stapling_verify on;

        location / {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot

I run the application on port 8081, as can be seen by through docker ps -a

CONTAINER          IMAGE          PORTS
e40c9815d6cc      mediawiki -> 80/tcp

I can access, but it shows the default Apache Ubuntu default page. Accessing other pages and resources (index.php, /folder/index.php, images/pic.jpg) returns 404.

Testing the container with similar setup on my machine works. I think there maybe something up I didn’t get with the NGINX config.


1 Answer

Hi @aerlaut!

Perhaps proxy_pass should be:


From what I understand is that, you want NGINX to listen on any IP address and network device in your server, at port 8081, (listen on and reroute that request to your local docker container on port 8081 (send to

Additionally what does nginx´s error log contains?

Have another answer? Share your knowledge.