nginx reverse proxy for docker containers

I'm trying to do something with nginx that i admittedly took for granted would be pretty easy.

I have a docker host with several web based containers, not all of them are on port 80, but i would like be able to access them with a standard URL.

I want to use an nginx container on the docker host to accomplish this.

So, using the standard nginx image , I created a .conf file for each of my containers. They look like this:

server {
listen 8080;

location / {
proxy_pass http://jenkins:8080/;

But there is something wrong with this approach because all URLs end up going to the jenkins server because it is the first one or some such.

I am assuming that the server\_name directive works the way Apache does name-based virtual hosting?

What am I doing wrong, or do I need to use the upstream directive instead?

I've actually got an entire course on nginx cued up to take, I just hoped that I could get this one thing going beforehand.

1 thought on “nginx reverse proxy for docker containers”

Leave a Comment