Valian / docker-nginx-auto-ssl

Docker image for automatic generation of SSL certs using Let's encrypt and Open Resty
https://hub.docker.com/r/valian/docker-nginx-auto-ssl/
MIT License
411 stars 103 forks source link

FORCE_HTTPS=false results in 404 #20

Closed dbackeus closed 5 years ago

dbackeus commented 5 years ago

When running the container with FORCE_HTTPS=false all requests over regular http result in 404 Not Found response while requests over https are still working fine. Looking at docker logs openresty I see the following:

2019/04/04 12:54:49 [error] 22#22: *13 open() "/usr/local/openresty/nginx/html/some/path" failed (2: No such file or directory), client: 83.145.8.46, server: , request: "HEAD /some/path HTTP/1.1", host: "openresty.mnd-static.com" 83.145.8.46 - - [04/Apr/2019:12:54:49 +0000] "HEAD /some/path HTTP/1.1" 404 0 "-" "curl/7.54.0"

I'm guessing this might be because https://github.com/Valian/docker-nginx-auto-ssl/blob/master/snippets/server-proxy.conf isn't actually configured to listen to port 80? Is that by design? If so what is the point of the ENV variable?

Valian commented 5 years ago

Hi @dbackeus!

Configuration for port 80 is declared in https://github.com/Valian/docker-nginx-auto-ssl/blob/master/nginx.conf. Role of FORCE_HTTPS=true is to add a default rule to redirect all traffic coming to port 80 to port 443 (you can find it here https://github.com/Valian/docker-nginx-auto-ssl/blob/master/entrypoint.sh#L56). Without it, there is no rule to handle HTTP traffic other than what's required to generate https certificate and a default nginx fallower behaviour (that is to serve files from /usr/local/openresty/nginx/html).

It's a pretty rare case that someone wants to use HTTP when HTTPS is configured, but if you want to change it you have to modify /usr/local/openresty/nginx/conf/resty-server-http.conf inside of the container. Hope it answers your question :)