[Solved] Ngnix as a reverse proxy does not work with domain no-ip

  • Platform information:
    • Raspberry pi 3_
    • OS: Openhabian
    • openHAB version:2.4
  • Issue of the topic:

I have installed ngnix in and installed the Dinamic udpdate client of no-ip in my openhabian installation I have also configured the ngnix of the following way:

server {
    listen                                    80;
    server_name                               domain_given_by_noip.com;

    location / {
        proxy_pass                            http://localhost:8181/;
        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;
        auth_basic                            "Username and Password Required";
        auth_basic_user_file                  /etc/nginx/.htpasswd;

    }
}

I carry out portforwarding in my router, my issue is that from external place of my internal network this acces is absolutely open trough “http://domain_given_by_noip.ddns.net:8181” , ngnix does not request user and password.
How Can I set up ngnix with this domain given by no-ip, I need to secure this remote acces.
If I replace this domain by the internal IP in ngnix configuration, and type in my browser locally http://internalIP ngnix request efectivelly user and password.

Thanks for your advises.

Try moving the auth_basic statements to the server block instead (before the location block).

Thanks for your suggestion but the problem persist, when configure nginx with proxypass directive it means that all request made to the port (listen directive) are redirected them to proxypass (e:g http://localhost:8080) but locally http://localhost:8080 is stiil open without protection, in my case this is my problem, when I write in my browser http://domain_given_by_noip.ddns.net:8080 is like I go directly to *http://localhost:8080 because my router by portforwarding made this redirection, what is the way indicate to nginix that when my router redirected from port 80 to port 8181 it (ngnix) take this port (8181) and protect this conection .

Thanks

This is because you bypass the proxy, which only listens on port 80. The web service of OH picks up this request…:blush:
So close port 8080 on the router.

1 Like

Hello Ron.

Your suggestion is right, after I’ve closed the port 8080, all works fine , I had the wrong idea that to have this port open was the only way to access remotely.

Thanks

Glad it works. :grin:

Glad your problem is solved, please click the square box (lower right corner) on the post that provided the solution (@noppes123 post) and edit the title to start with [Solved]. This will help other with a similar situation fine a quick solution.

Thanks