[SOLVED] OpenHAB Android app not working with nginx reverse proxy

I am using the newest version of the openhabianpi image and configured authentication with nginx as described here: https://www.openhab.org/docs/installation/security.html#options-for-secure-remote-access
Everything works fine with a web browser but not with the openhab android app. I just get the spinning circle on the home screen but the page isn’t loading. I have set the correct credentials in the settings of the app.
The connection itself seems to work, because when I put in a wrong password I get an authentication error on the home screen. Is this a known issue?
Here’s my nginx config:

# Default server configuration
server {
        listen 443 ssl;
        listen [::]:443 ssl;

        server_name             openhabianpi.;
        ssl_certificate         /etc/ssl/openhab.crt;
        ssl_certificate_key     /etc/ssl/openhab.key;

        location / {
                proxy_pass                    ;
                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                              "";
                auth_basic_user_file                    /etc/nginx/.htpasswd;

server {
        listen 80;
        listen [::]:80;
        server_name openhabianpi.;
        return 301 https://$server_name$request_uri;

Any ideas?

I fixed this now by changing line
proxy_set_header Host $http_host;
proxy_set_header Host openhabianpi:8080;

1 Like

Hi Christoph I noticied ni your configuration you have the htpassword auth setup, how does that work when you use your Android App? Doesnt it break?


I am not sure what you mean (probably because I am not an expert when it comes to webservers, proxy etc.).
However, you can provide access credentials in the settings of the android app. So just put in the credentials from the htpasswd there and it should work.

1 Like

I’m aware of where to provide access credentials. What is confusing is when you register on your openhab cloud instance on the http://:3000 - is that the user/password that gets entered into the Android app?

If so, which is what im using, why do you have a htpassword file on your NGINX configuration?

Doesnt make any sense to me why you register and create a password in openhab cloud to use somethign entirely different in the proxy config

What do you mean when you talk about openhab cloud?
I only have one openhab instance which is on the same device as the proxy. And I don’t use port 3000 somewhere.
I only have one username/password and this is defined with htpasswd

Openhab cloud requires you to register on its webpage which by default runs on port 3000.

That registration requires an email and password - that, I assume is what you use to login.

htpassword is a nginx specific thing to protect websites, not the mechanism used for OH2 Cloud as far as I’m aware.