Hello everyone,

I have an environment with 3 containers and I also have a domain www.example.com with my app in production.

I would like to implement mediawiki with the pattern address like www.exemple.com/wiki

I tried to redirect any call for www.exemple.com/wiki to my mediwiki container and it works, but the address changes to www.exemple.com:8080/wiki

This is my compose file:

...
app:
  build: ./app
  command: python manage.py runserver 0.0.0.0:8000
  ports:
   - 8000:8000

nginx:
  build: ./nginx
  ports:
    - 80:80
    - 443:443

wiki:
 build: ./wiki
 ports:
   - 8080:80

And this is the nginx.conf

upstream example {
    server app:8000;
}

upstream wiki {
    server wiki:80;
}

server {

    listen 80;

    client_header_timeout 3000;
    client_body_timeout 3000;
    fastcgi_read_timeout 3000;
    client_max_body_size 32m;
    fastcgi_buffers 8 128k;
    fastcgi_buffer_size 128k;

    location / {
        proxy_pass http://example;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
    }

    location /static/ {
        alias /home/app/web/static/;
    }

    location /wiki {
        proxy_pass http://wiki;
        rewrite ^/wiki(.*) /$1 break;
    }
}

There is a way to configure it and stop showing its port address?
What i’m missing? if there is a better way to do that, I’m open to suggestions.

Thanks

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.

×
1 answer

Hello,

Your configuration looks correct actually.

What happens when you visit your IP address on port 80?

You can take a look at this answer here but your approach is also correct:

https://www.digitalocean.com/community/questions/how-to-host-multiple-docker-containers-on-a-single-droplet-with-nginx-reverse-proxy

Submit an Answer