Hi all,
I’m new to firewall on mikrotik. I would like to redirect traffic destined to a specific port, to another port.
Explanation: I have a webserver accepting connections on port 80. On the same machine, I have a docker bound to port 3000. I would like to kind of rewrite the destination port, from 80 to 3000. That way, if I type “www.example.com” I get the webserver homepage, but if I type “www2.example.com”, The connection would be sent to the port 3000.
I have tried many things:
- Use Firewall/NAT on dst-nat to port 3000. It works but it can’t be filtered using the “content” field. Empty, it matches any packet and the result is what I want. But I would like to filter the content with: “Host: www2.example.com”
- Maybe packet content isn’t accessible before pre-routing. So I tried to mangle them, and it works! I can add a connection-mark then a packet-mark filtered by the “content” field. Great. But now I can’t route them on the est-port needed. Apparently, there is strictly no action on any chain being able to do what I want with a marked-packet.
- There are 2 routers between me and the servers. I thought about marking the packets in the previous router and dst-nat accordingly on the second. But marks don’t leave the router using them.
- I thought about a way to send back the marked packet to the beginning of its flow, then I could dst-nat it, but I don’t find how.
Any idea on how to achieve that, only using the mikrotik firewall?