I have a NGINX listening on port 441 and SSLH listening to ports: 441(https), 442(ssh) and finally STUNNEL listening on port 443 forwarding to SSLH(port 2243).
STUNNEL config:
pid = /var/run/stunnel.pid
cert = /etc/letsencrypt/live/f1.example.com/fullchain.pem
key = /etc/letsencrypt/live/f1.example.com/privkey.pem
[sslh]
accept = 443
connect = 127.0.0.1:2243
SSLH config:
DAEMON_OPTS="--user sslh --listen 127.0.0.1:2243 --ssh 127.0.0.1:442 --ssl 127.0.0.1:441 --pidfile /var/run/sslh/sslh.pid"
NGINX config:
server {
server_name f1.example.com;
listen 441;
access_log /var/log/nginx/f1.access;
error_log /var/log/nginx/f1.error;
location /admin/ {
proxy_pass http://127.0.0.1:10000/;
proxy_set_header Host $host;
proxy_redirect http://$host:10000/ /admin/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
return 302 https://$host$request_uri;
}
As you can see I am running a WEBMIN App in /admin/ path with a reverse proxy using NGINX. My problem here is when I just type f1.example.com/admin in the browser, it redirects to HTTPS version which is https://f1.example.com/admin.
After a successful login it redirects to http://f1.example.com:441/admin/sysinfo.cgi?xnavigation=1 which is in HTTP with port 441(I am wondering how port number getting inserted here). The page loads fine but its not in HTTPS. I have to manually remove the port number and hit enter to get it upgraded to HTTPS.
How can I get this to work with HTTPS smoothly? What are the changes I need to do to my NGINX conf file? I feel like I am missing something here.