server { listen 80; listen [::]:80; server_name account.*; location / { proxy_redirect http://127.0.0.1/ https://$host/; proxy_pass http://oathkeeper:4455; } } server { listen 80; listen [::]:80; server_name secure.*; if ($host ~ secure.(.*)) { return 301 $scheme://account.$1$request_uri; } }