Routing docker conainter to path using port 80

2

I have a docker image that I can access via domain.com:8080/ from any computer. But I cant get it redirect to domain.com/service/

UPDATED: found my answer, see below.

mjh

Posted 2016-12-07T09:47:52.827

Reputation: 21

So you want to redirect domain.com:8080 to domain.com/service/? You can do that in the Nginx on docker right? Just make sure the server at domain.com:8080 sends an HTTP 301 back to the client. – mtak – 2016-12-07T10:07:53.807

just so I am sure I am getting it, this is what it would look like, yes?

    listen 8000;
    server_name www.domain.com;
    return 301 $scheme://www.domain.com/service;
}```
 – mjh  – 2016-12-07T12:51:07.553

Where does 8000 come from? In your question it says 8080. – mtak – 2016-12-07T13:45:59.000

was a bit too quick for my comment sry. Yes 8080. – mjh – 2016-12-07T13:59:58.127

Answers

0

So just to summarize, I have found the answer.

I can't use jwilder/nginx as that is only for hostnames - so I have to use nginx on the host server to rewrite a rule. I am still using docker-compose with my editted hosts file so that I have easier access locally between containers, but my rewrite rule binds on the port I have exposed.

mjh

Posted 2016-12-07T09:47:52.827

Reputation: 21

0

This redirection should be configured for web server listening to port 80 of domain.com. Under assumption you've mentioned details of your container, you should publish port 80 from your container docker run ... -p 8080 -p 80 ... and configure this redirections in the configuration of nginx.

Moisei

Posted 2016-12-07T09:47:52.827

Reputation: 131

Thanks checking if it works. As a follow up what about the reverse proxy nginx docker image, is that a possibility? – mjh – 2016-12-07T12:44:46.770