Problem with accesing OpenHAB2 site from outside without (nginx + reverse proxy with redirection)

Hello all,

I have a problem with configuring openHAB2 to work form outside my home network without myopenhab .org.
To do that, becouse my ISP provider uses double NAT and i have no access to external IP i have bought portmap .io OpenVPN service with port forwarding.

So, my network on Khadas VIM2 board looks like:
Home network at eth0:
OpenVPN connection at tun0:
And of course lo interface…

at portmap .io I have forwarded port 80 through http protocol to (virtual host like redirection - i think)

OpenVPN connection is working. When I install nginx, default nginx page was displayed from outside.
I have made new server configuration for nginx with looks like:

server {
    listen                          80;
    server_name           ;

    location / {

    location /oh2/ {
        proxy_pass                              http://localhost:8080/;
        proxy_redirect                          http://$host/ /oh2/;
        proxy_set_header Host                   $http_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                         ;
        allow                         ;
        deny                                    all;
        auth_basic                              "Username and Password Required";
        auth_basic_user_file                    /etc/nginx/.htpasswd;

I don’t want to use root directory becouse I want to host some more services through nginx.
I know it is a very insecure configuration. I made it more secure later if it will work.

For now I have a problem with nginx.
When I open openHAB2 site from Khadas ( and also form my local network directly or through nginx ewerything works perfectly.
When I try to open openHAB2 from outside when i type nginx redirects it to and of course it cannot be reached because address is not an external one.

When I have changed
proxy_redirect http://$host/ /oh2/;
proxy_redirect http://$host/;

I can connect form outside, site is password protected as configured, but also form local adresses I am redirected to external adress. And I am still not satisfied with these.

How can I do these to redirect 192.168.x.x adresses to /oh2/ and 10.x.x.x to “”.

Second thing with I have problem is openHAB2 mobile app.
Local connection to works perfectly.
Local connection to can’t connect (of course i have placed login and password also)
Remote connection to can’t connect (of course i have placed login and password also)

Can anybody can help me out?

btw. sorry for my english :slight_smile: