HABot behind Apache2 reverse proxy

apache2.4
reverseproxy
habot
Tags: #<Tag:0x00007f01485eefc0> #<Tag:0x00007f01485eee80> #<Tag:0x00007f01485eed40>

(Miika Jukka) #1

Hi,

HABot looks very promising and I have been testing it for a while only inside my lan. Now I would like to access it from wan side. I’m running Apache 2 as a reverse proxy. I’ve configured it this way: Apache2 reverse-proxy with LDAP-authentication, HTTPS and URL-path-prefix

Everything else is running nicely but HABot main page shows just blank white. It connects and looks like it’s loading for a while like it should but nothing shows.

Confirmed that this “use compresed web app resources” option is unchecked.

Tried to clear browser cache and used incognito mode to access HABot. Now it shows sad face and says that openHAB is offline.

Any ideas?

Running openHAB 2.4 Snapshot #1460 on Debian 9 and Zulu Java

Edit #1 Looks like the problem is with substitution rules…


(Yannick Schaus) #2

Can you open the dev tools and check if there are errors? I think URL prefixes (e.g. https://host/openhab) are not supported, it should be at the root of the domain.


(Miika Jukka) #3

Got this bit further. Opening https://mydomain.net/openhab/habot/ now displays HABot’s main page correctly. Two RewriteRules and substitution got this working. Main problem was accessing REST api. Now I can change settings and add cards etc. But as soon as I say something to HABot it answers “HTTP 405 Method Not Allowed”. Looks like POST requests are not allowed. I’ll continue my experiments and speed them up with a cold beer.

Edit #1 POST method is allowed. And so is GET. Problem now seems to be that the request redirection is not working.

Edit #2 Redirection is working but /rest/habot/chat accepts only POST. Apache is converting the POST request to GET and thats why the answer is not allowed.


(Miika Jukka) #4

It’s working! I’ll do some tests and make sure that i have nothing cached. After that I’ll post the solution.


(Miika Jukka) #5

For now I have these lines added to openhab-ssl.conf:

RewriteRule "/openhab/rest/openhab/habot/(.*)$" "http://localhost:8080/rest/habot/$1" [P,L]
Substitute "s|/habot/|/openhab/habot/|n"

It’s working like it should but when you look at the first line, it looks a bit akward and can be enhanced a abit. I’'ll see what I can come up with.


(Miika Jukka) #6

More tests revealed that it isn’t fully working. If I create a card named kitchen that holds a group item containing kitchen lights and ask HABot “show kitchen” the card is displayed correctly. But if I ask “show lights” so that it creates the card “on the fly” containing all my items tagged with lights chrome debug console shows TypeError.

TypeError: t.style is undefined
Stack trace:
Qr@https://xxx.xxx.xxx.xxx/habot/js/vendor.718c1ac.js:21:50454
Jr@https://xxx.xxx.xxx.xxx/habot/js/vendor.718c1ac.js:21:51019
w@https://xxx.xxx.xxx.xxx/habot/js/vendor.718c1ac.js:21:42087
d@https://xxx.xxx.xxx.xxx/habot/js/vendor.718c1ac.js:21:41011
b@https://xxx.xxx.xxx.xxx/habot/js/vendor.718c1ac.js:21:41854
d@https://xxx.xxx.xxx.xxx/habot/js/vendor.718c1ac.js:21:40996

I’m now accessing habot https://my.domain.com/habot/ and not …/openhab/habot. I have separate configs under apache.

I’ve been thinking to create another subdomain and virtual host but don’t know if it would make any difference.

Edit #1 I changed kitchen lights from colour item to dimmer item and now it seems to work? Weird.


(Yannick Schaus) #7

That’s a weird bug, I don’t have encountered it before. :confused:
Does that happen as well if you open HABot locally (without the reverse proxy)?


(Miika Jukka) #8

No.

I created a card with a knob in it and the same error apears.