Proxying OTGW web server - absolute URLs

This Forum is about the Opentherm gateway (OTGW) from Schelte

Moderator: hvxl

Post Reply
Stachel
Starting Member
Starting Member
Posts: 8
Joined: Sat Nov 15, 2014 3:03 pm

Proxying OTGW web server - absolute URLs

Post by Stachel »

I'm playing a bit with otmonitor (4.2.1) running as a daemon on my Raspberry Pi. I like the web interface a lot, it also appears to be more stable than access OTGW values from within Domoticz (lock ups).

Since I use Nginx already to access Domoticz (because I want HTTPS access, which was not available until recently in native Domotic) I decided to use it as a front-end for the OTGW web server as well.

I proxy the location '/otgw/' to the local port on which OTGW is listening, like so:

Code: Select all

  location /otgw/ {
     proxy_pass http://localhost:8081/;
     proxy_redirect default;
     proxy_set_header        Host            $host:$server_port;
     proxy_set_header        X-Real-IP       $remote_addr;
     proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  }
This works - sort of: I get the main page with the status overview, but stylesheets, images and links to for example the graph are not working because they are absolute to the webroot. This means that: '/status.html' does not get proxied to '/otgw/status.html' ( which would work), but to '/status.html', which does not exist.

Would it be possible to either replace the absolute URLs with relative URLs, or to replace them with the complete URL (i.e. including host name) so that there's a pattern in the URL that I can rewrite with Nginx directives?


Edit: should have been posted in OTGW subforum - sorry.
--
Martijn
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: Proxying OTGW web server - absolute URLs

Post by hvxl »

I use reverse proxying (with apache) in other situations myself, so I know how useful it can be. I don't know why I didn't think to make that possible by using relative URLs in this case. There seems to be no reason why the URLs should be absolute. I will make that chance in the next version. Thanks for the suggestion.

You know you can run otmonitor in source form and make the changes yourself if you don't want to wait for the next version? See the Opentherm Monitor Sources page for more information.
Schelte
adijk
Starting Member
Starting Member
Posts: 18
Joined: Fri Dec 13, 2013 5:29 pm

Re: Proxying OTGW web server - absolute URLs

Post by adijk »

Maybe it's also a goot idea to make a configurable webroot in otmonitor, for those of us using proxypasses?

So to make all html-requests go under, for example, /otgw/status.html where the /otgw-part is configurable?
Ghostbird
Starting Member
Starting Member
Posts: 14
Joined: Wed Mar 11, 2015 8:03 pm

Re: Proxying OTGW web server - absolute URLs

Post by Ghostbird »

I think the easiest way to do this is to download the sources and the tclkit and then run it that way. You can then modify the application to work with a different directory structure.
I did a quick grep on the sources:

Code: Select all

$ grep -n docpath *.tcl
gui.tcl:1302:    global cfg wibblesock theme docpath webstatus
gui.tcl:1305:    foreach dir $docpath {
otmonitor.tcl:18:set docpath {}
otmonitor.tcl:28:lappend docpath [file join $starkit::topdir docroot]
otmonitor.tcl:34:lappend docpath [file join [file dirname $starkit::topdir] html]
web.tcl:374:foreach n $docpath {
It seems to me that the variable docpath constructed in otmonitor.tcl is responsible for pointing the system to the right directories.
However there's no actual html folder as far as I can see, so that may be a runtime Wibble construct, or I may have misunderstood the purpose of otmonitor.tcl:34
You can give it a try, I think the files you'll probably need to modify are web.tcl for the webserver and otmonitor.tcl for the configuration.
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: Proxying OTGW web server - absolute URLs

Post by hvxl »

adijk wrote:Maybe it's also a goot idea to make a configurable webroot in otmonitor, for those of us using proxypasses?
Once the URL's have been made relative, it's completely unnecessary to make the webroot in otmonitor configurable. With the right proxypass settings it will be possible to access all information presented by the web server, including the websockets.
Schelte
bazb
Starting Member
Starting Member
Posts: 1
Joined: Sat Apr 25, 2015 2:01 pm

Re: Proxying OTGW web server - absolute URLs

Post by bazb »

You can also fix this with nginx with the HttpSubsModule. You can then rewrite the paths on the fly.
The easiest way is just to use a subdomain instead of a subfolder.
Post Reply

Return to “Opentherm Gateway Forum”