Forum

Redirect to internal IP

Sergeyk
3 November 2016, 18:24
Hi,
this is continuation of our 1st question concerning redirection: https://www.hiawatha-webserver.org/forum/topic/2367
We have tried your suggestion to redirect all requests to some subfolder to another IP. But it seems it doesn’t work.
1st of all we are using Hiawatha v9.2 – should it support this UrlToolkit?
2nd – I want to emphasis the fact that redirected IP is not seen from the outside. We have one WEB server Hiawatha running on IP-1 and second WEB server running on on IP-2. IP-2 is not exposed, it means there is no ping from some client’s equipment to IP-2, it can ping only IP-1. So, in order to see the second WEB site, Hiawatha should work as a proxy.
Is this redirection mode using UrlToolkit should do the work in this case?

Thanks.
Hugo Leisink
4 November 2016, 00:31
Ah, I forgot that the second server is not reachable from the outside. Try this instead:
VirtualHost {
...
ReverseProxy ^/somefolder/.*\.html http://192.168.6.6/
}

Add 172.26.5.5 to the Hostname of the virtualhost at 192.168.6.6. Because an IP address is used for the backend server (192.168.6.6.), Hiawatha will use the hostname (172.26.5.5) as received in the first request in the request forwarded to 172.26.6.6.
Sergeyk
4 November 2016, 18:25
Hi,
Many thanks for your explanation. But I think there is still a problem with the subfolder redirection. Because of we have 2 independent WEB sites – one on 172.26.5.5 and second on 192.168.6.6, but we want to access 192.168.6.6 via 172.26.5.5, and I thought it can be possible to achieve by means of some “virtual” non-existent folder. In other words I want to substitute address 172.26.5.5/somefolder/somepage for 192.168.6.6/somepage (192.168.6.6 WEB doesn’t contain somefolder!). On other hand, all requests to 172.26.5.5/anypage should continue to work, as it was working all the time.
But as I understand, the VirtualHost rule
ReverseProxy ^/somefolder/.* http://192.168.6.6/

will cause requests to be redirected to http://192.168.6.6/somefolder/..., that is incorrect in our case.

Another idea we have is to run proxy server on 172.26.5.5 at some separate port, e.g. 81. Thus it can be redirected from 172.26.5.5:81 to 192.168.6.6.

Can you pls advise?

Thank you again.
Hugo Leisink
4 November 2016, 18:54
Try this one:
ReverseProxy ^/somefolder/.* 1 http://192.168.6.6/
Sergeyk
5 November 2016, 11:37
After adding this section to the configuration:
VirtualHost {
Hostname = 172.26.5.5
ReverseProxy ^/test/.* 1 http://192.168.6.6
}

I completely have lost the access to my device (172.26.5.5) via the WEB. Where is my mistake?
Sergeyk
10 November 2016, 18:25
Found another decision: Linux utility named socat does this work very fine. E.g.
socat TCP-LISTEN:81,fork TCP:10.0.0.1:80

is all what was needed.
This topic has been closed.