Forum

Using multiple ReverseProxy entries to access different hosts in the LAN

Midnight
8 September 2014, 17:12
Hiawatha version: 9.7
Operating System: some Linux

Hi,

I want to setup Hiawatha to act as reverse proxy for different services and hosts in my LAN. Therefore Hiawatha should have HTTPS and password protection enabled, because some of the services/hosts don't offer this themselve.
But it seems it is not possible to set up Hiawatha like this:
ReverseProxy ^/service1/.* http://192.168.1.101/ 30
ReverseProxy ^/service2/.* http://192.168.1.102/ 30
ReverseProxy ^/service3/.* http://192.168.1.103:8080/ 30
ReverseProxy ^/service4/.* http://192.168.1.104:5000/webmin/ 30


The problem here is that the matching directory always gets appended to the destination instead of just passing everything after the matching dir to the destination.
Any ideas or suggestions?
Hugo Leisink
8 September 2014, 17:24
This is how the reverse proxy works. What you should do is use different hostnames for each service.
Midnight
9 September 2014, 09:19
OK, but that would require to register a DynDNS domain for each service.
Could you give a hint what source file I could edit to change the behaviour how the destination is put together?
Hugo Leisink
9 September 2014, 11:24
Just register one domain (domains are very cheap these days) and use a different hostname within the domain, like service1.domain.com, service2.domain.com.

Most reverse proxy stuff is in src/rproxy.c. There is also the proxy_request() function in src/target.c. What you should look at is line 405 (v9.6) in src/rproxy.c, the sending of the URI via send_to_webserver(). The tricky part is that the matching URI of the reverse proxy configuration is a regular expression, not a plain text string. So, what part should be stripped from the request URI?
Midnight
9 September 2014, 15:04
Thanks! After looking at the source and reading your explanation about the regex again I've realized what's the problem here
This topic has been closed.