My docker compose looks like this:
version: '3.2'
services:
mediawiki:
image: mediawiki:lts
nginx:
image: nginx:stable-alpine
depends_on:
- mediawiki
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- 80:80
#...
Where mediawiki is a docker container that runs on port 80 in docker and does not appear to have a way to change the port number.
I'm trying to expose mediwiki through ngninx and the nginx config looks like this:
events {
}
http {
server {
listen 80;
location / {
client_max_body_size 2M;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
proxy_pass http://mediawiki:80;
}
}
}
Since both nginx and mediawiki is running at port 80, I can't set portmap mediwiki 80:80.
I've tried mapping it to another port under mediawiki such as 7001:80 and in nginx config replace http://mediawiki:80 with http://mediawiki:7001 but this produces bad gateway error when loading the site url at port 80.
How might I fix this?
Let's have a look at
reverse proxyin which case I use.This should be your
wiki.confcontents:And add a
Dockerfilein the directory where yourdocker-composefile is:And keep your
nginx.confas default values, or change some values on your own but do not add any directives to servewiki.You can replace
THE_DOMAIN_NAME_OF_YOUR_MEDIAWIKIwit the actual domain name. Like if you havemedia.comand yourwikiwants to be accessible atwiki.media.com.Now you can run
docker-compose up -d --buildand see the result.