0

I have Nginx running on Ubuntu20 with a proxy_pass from https://example.com to 0.0.0.0:8000 which is a docker container. When I hit https://example.com/literally/any/path/at/all the proxy works as expected, but when I hit the root path https://example.com I get a 301 redirect to https://docker:8000. I don't understand why the sub-paths get proxied fine but the root path gets a redirect.

My Nginx site config:

upstream docker {
    server 0.0.0.0:8000;
}


server {
    listen 80;
    server_name example.com www.example.com mail.example.com;

    location /.well-known {
        alias /ssl/well-known;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

server {

    listen 443 ssl;
    server_name example.com www.example.com mail.example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/cert.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://docker;
    }
}

0 Answers0