Community discussions

MikroTik App
 
knut
just joined
Topic Author
Posts: 13
Joined: Tue May 18, 2010 12:50 pm

Incoming forwarding / Proxy based on URL

Wed Aug 26, 2015 10:33 pm

I have several http servers: (mail, web) in my DMZ. I want to forward incoming traffic to the respective servers based on url, f ex:
www.mydomain.tld -> mywebserver
mail.mydomain.tld -> mymailserver
How can this be done? I understand that NAT is not an option, because NAT forwarding is established before the url is received, but it could maybe be done by using Web Proxy.
Can anybody please tell me how to configure the router to achieve this?

thank you
Knut
 
User avatar
lordkappa
Member Candidate
Member Candidate
Posts: 133
Joined: Wed May 16, 2012 1:53 pm
Location: Vancouver, Canada

Re: Incoming forwarding / Proxy based on URL

Thu Aug 27, 2015 2:40 am

If you're using HTTP, (Bad bad, you should be using HTTPS) then you can use a regular expression to tag the connection in Prerouting, and use NAT rules from there. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html for HTTP GET request structure. This will work because Mangle Prerouting happens before dst-nat. See here: http://wiki.mikrotik.com/wiki/Manual:Packet_Flow.

If you're using HTTPS, this is impossible, as the router cannot see the URI being requested. You would need to do SSL termination in a separate box/load balancer.