Thank you Tom!
Following your suggestions, I finally managed to find a working configuration for my scenario. Here it is, complete with https:
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate <...>/fullchain.pem;
ssl_certificate_key <...>/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
location / {
proxy_pass http://<internal ip addr>:<internal port>;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
}
}
A couple of remarks:
- we need to set X-Forwarded-Proto for https to work; still, other X-Forwarded-* settings seem to have no effect on returned location (unless I did something wrong), only setting Host works
- since we have an external port remapping service in front of the reverse proxy, we need to set the outgoing Host header with the $http_host nginx variable, which returns the full incoming Host header content, and not for example $host:$server_port
Thank you again for the prompt support! I'm sure this can help other people too.