Hello all, i’d kindly ask for some guidance in getting my nginx up and running.
I realise this might be really basic for you guys, considering how advanced feel your posts so far… it isn’t for me.
Following
and the first post in this thread and a number of other guides regarding certbot and let’s encrypt:
I breezed through the steps with no issues up until managing to get my certs with let’s encrypt+certbot where i’ve hit the first hurdle.
After quite some bickering vs my ISP supllied router not applying nat and firewall changes (massive loss of time
) i moved forward.
As long as i have listen 80;
without ssl and without the 301 redirection from 80 to https+443, my nginx config works - i have at least achieved authentication. This has been my failsafe step back for 10 days now 
As soon as i switch to listen 443;
, move to any browser on any device (with cleared cache, cookies, session etc, having done sudo nginx -t
+ sudo service nginx restart
) if i call to my Rpi’s internal ip via https://192.168.1.32:443
i get a neverending blank loading page. if i just type in the ip (meaning http+80) i get a “page not available” error page.
I’ve tried swapping back in “mydomain_or_myip” instead of any of the actual 2 values, however the only way i can get through this step is by swapping in as proxy_set_header Host $proxy_host
and keeping the “mydomain_or_myip” server name; this way i can get to authenticate from the LAN calling the ip with https+:443, and the browser asks me to accept the certificates and authenticate.
So i then follow up adding in the 301 redirection server block.
If i have as proxy_set_header Host $proxy_host;
i get an error "page unreachable https://mydomain_or_myip
"
So the 301 redirection from http+80 to https+443 happened, but somehow it doesn’t get into openhab’s location.
Out of curiosity, if i swap back in $http_host
there is no difference.
So i back i go to $proxy_host
, but with no valid result yet.
one last thing i thought of doing was to swap in my actual domain’s name in the 301 server name block.
This is a funny one!
Basically that means the call would go from
my pc>http>rpi>(asks to accept certs)https>dyndnsprovider>myrouter(blocks it, but i could open port 443 too…)>my rpi
The funny thing is, i have the feeling this one would work
, but i find that the whole point of making that 301 was to make some kind of a localhost translation from http to https, otherwise if i have to open both 80 and 443 on my superresponsive ISP provided router, then i might just have opened 443 in the first place without the 301 redirect and opening port 80.
So i’ve tried changing the 301 server name for localhost
- doesn’t work, i think it tries to resolve it on the pc i’m browsing on
.
So i’ve tried swapping in for the 301 server name the actual ip of the Rpi -192.168.1.32 and obviously in LAN it works, but as soon as i try and connect from outside, my tablet or phone starts looking for 192.168.1.32 in whatever network i happen to be (this could get even funnier if there is an actual something on that netwrk’s address)
please please please help, i’m so lost i’m almost delirious…
this is my nginx file
server {
listen 80;
server_name mydomain_or_myip;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name mydomain_or_myip;
ssl_certificate /etc/letsencrypt/live/brandolin1.homepc.it/fullch$
ssl_certificate_key /etc/letsencrypt/live/brandolin1.homepc.it/privke$
add_header Strict-Transport-Security "max-age=31536000";
location / {
proxy_pass http://localhost:8080/;
proxy_buffering off;
proxy_set_header Host $proxy_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-Proto $scheme;
satisfy any;
allow 127.0.0.1;
deny all;
auth_basic "Username and Password Required";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location /.well-known/acme-challenge/ {
root /var/www/mydomain;
}
}