OH 3 behind nginx

Hi,

i’m migrating my openhab2 installation to openhab 3. My openhab is behind a nginx with authentication because of security reasons.

The installation was absolutely problem-free. But OH3 don’t want work behind my nginx.

If i use the default url http://xxxxxx:8080 there is no problem. The nginx listen to port 8081 and points to port 8080. I only see an empty side :frowning:

In the browser i see some 401. This is my nginx configuration.

server {
  listen             8081 ssl;
  server_name        XXX.com;

  ssl_certificate     /etc/letsencrypt/live/XXX.com/fullchain.pem; # or /etc/ssl/openhab.crt
  ssl_certificate_key /etc/letsencrypt/live/XXX.com/privkey.pem;   # or /etc/ssl/openhab.key
  add_header          Strict-Transport-Security "max-age=31536000";

  location /logs {
    satisfy                                 any;
    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;
    proxy_set_header Connection             "Upgrade";
    proxy_set_header Upgrade                $http_upgrade;
    proxy_pass                              http://localhost:9001/logs;
    auth_basic                              "Username and Password Required";
    auth_basic_user_file                    /etc/nginx/.htpasswd;
  }

  location / {
    proxy_pass                              http://localhost:8080/;
    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;
    proxy_set_header Upgrade                $http_upgrade;
    proxy_set_header Connection             "Upgrade";
    satisfy                                 any;
    auth_basic                              "Username and Password Required";
    auth_basic_user_file                    /etc/nginx/.htpasswd;
  }
} 

Can anyone please help me
BR

check if this thread OH3 with NGINX Reverse Proxy and Authentication helps

1 Like

Oh. I’m sorry i did not find this solution :frowning: Now it works!

1 Like