I thought I would leave this here for anyone trying to get reverse proxying to a service hosted on a different server and getting a letsencrypt certificate issued for the service.
I have spent the last 6 hours trying to get this working and finally is working.
root@host:/usr/local/hestia/data/templates/web/nginx/php-fpm# cat archive.tpl
server {
listen %ip%:%web_port%;
listen 80; # Probably not needed but had nat issues
listen [::]:80; # Probably not needed but had nat issues
server_name %domain_idn% %alias_idn%;
return 301 https://$host$request_uri;
access_log /var/log/nginx/domains/%domain%.log combined;
access_log /var/log/nginx/domains/%domain%.bytes bytes;
error_log /var/log/nginx/domains/%domain%.error.log error;
# ACME challenge (comment out the following lines or remove them)
#location ^~ /.well-known/acme-challenge/ {}
#include /home/ukpoliticsdecoded/conf/web/archive.ukpoliticsdecoded.uk/nginx.conf_*;
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
# Static files (critical)
location /static/ {
proxy_pass http://192.168.60.116:8000/static/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
}
# Admin UI
location /admin/ {
proxy_pass http://192.168.60.116:8000/admin/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
}
# Public UI
location / {
proxy_pass http://192.168.60.116:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
}
location ~ /\.(?!well-known\/) {
deny all;
return 404;
}
}
If you are getting not secure on Chrome change:
proxy_set_header X-Forwarded-Proto http;
change it to:
proxy_set_header X-Forwarded-Proto https;