Community discussions

MikroTik App
 
mike6715b
newbie
Topic Author
Posts: 34
Joined: Wed Feb 17, 2021 9:07 pm

DIfferent port-forwarding based on domain

Sat Jun 05, 2021 1:02 am

Hy all, the situation is as follows...
We have a RDP Gateway running on our server on port 443 and we also wish to host a HTTPS website on a linux server also on port 443.

What I am wondering is if there is a way to run some sort of reverse-proxy on the Mikrotik to achieve this? Eg.
rdgateway.domain.com ---> server1:443
www.domain.com, domain.com ----> server2:443 (website)

From googling, I've seen people just straight up just say impossible and some saying it could be done with a custom script (but no other explanation, just that it could be done with a script) and one post saying something about mangle prerouting and using it to mark packets based on the domain but I haven't touched mangle and don't know how to work with it.

One other possible solution comes from a comment on the some "one post" saying:
You simply create the L7 regex rules and then the NAT rules that will dst-nat the matched packets to the configured IPs/Ports.

One way i thought of was setting up a SRV record (since we don't want to have to add ports, just the domain) on Cloudflare and route all rdgateway.domain.com traffic to port 444 and on mikrotik route incoming 444 traffic to server1:443 but I am hoping this could be achieved just with our Mikrotik.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11381
Joined: Thu Mar 03, 2016 10:23 pm

Re: DIfferent port-forwarding based on domain

Sat Jun 05, 2021 10:48 am

It can't be done with mikrotik only. L7 is too late in the game to make redirection working (it works fine as firewall rule because it can break connection at some later stage) and other criteria don't care about SNI (Server Name Indication) which is the only way of getting domain name of intended server. (And SNI is getting phased out with newer versions of TLS anyway, being replaced by ESNI).

Who is online

Users browsing this forum: No registered users and 70 guests