Docker and jwilder / nginx-proxy http / https

I am using docker in osx via boot2docker

.

I have 2 hosts: site1.loc.test.com

and the site2.loc.test.com

docker host IP is specified.

Both must be accessible via ports 80

and 443

.

So I am using a jwilder/nginx-proxy

reverse proxy for purposes.

But actually, when I run them all through docker-compose

every time I try to open through the port 80

, I get a redirect to 443

(301 Moved Permanently)

.

Maybe I missed something in the config jwilder/nginx-proxy

?

docker-compose.yml

proxy:
  image: jwilder/nginx-proxy
  volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro
    - certs:/etc/nginx/certs
  ports:
    - "80:80"
    - "443:443"

site1:
  image: httpd:2.4
  volumes:
    - site1:/usr/local/apache2/htdocs
  environment:
    VIRTUAL_HOST: site1.loc.test.com
  expose:
    - "80"

site2:
  image: httpd:2.4
  volumes:
    - site2:/usr/local/apache2/htdocs
  environment:
    VIRTUAL_HOST: site2.loc.test.com
  expose:
    - "80"

      

+3


source to share


2 answers


I think your config should be correct, but this seems to be the intended behavior jwilder/nginx-proxy

. See these lines in the file nginx.tmpl

: https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl#L89-L94

It seems that if a certificate is found, you will always be redirected to https.




EDIT: I found confirmation in the documentation

Proxy server behavior when opening ports 80 and 443 is as follows:

  • If the container has a usable certificate, port 80 will redirect to 443 for that container so that HTTPS is always preferred when available.

You can use custom config . You can also try overriding the file nginx.tmpl

in the new Dockefile.

+3


source


To update this topic, jwilder / nginx-proxy launched for this flag: HTTPS_METHOD=noredirect

; To be set as an environment variable.



Further reading on github

+3


source







All Articles