I am attempting to set a reverse proxy using the nginx container with a few other containerized app being routed too behind. I have modified the default.config in nginx to below. I have not changed anything in nginx.config
.
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /mailhog {
proxy_pass http://mailhog:8025;
}
location /httpd {
proxy_pass http://httpd:8080;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
My dockerfile uses the nginx image and just replaces the default.config.
Docker run command
docker run -d --name mailhog -p 8025:8025 mailhog/mailhog
docker run -d --name httpd -p 8080:80 httpd
docker run -d --name mynginx --link=httpd --link=mailhog -p 80:80 mynginx
When I navigate to / I get the standard nginx index page. Mailhog give a 404 and httpd give a 502. I have tried a couple variations of the docker runs command such as using --expose
or not opening any ports. If I navigate the actual url, the apps work fine, just not through the reverse proxy.
I got this strategy from here. I have looked at using nginx-proxy
but I don't want to use subdomain.domain url pattern.