I'm using Ubiquiti to route certain outgoing ip-ranges through a VPN. I would however like to route all HTTP/HTTPS traffic via the VPN except large downloads.

I realize that this is a tall order, but is it possible? Maybe after detecting a certain amount of bytes it could just reroute the connection and resume it without going over the VPN?

  • 1
    Routing is done by the destination IP address, and each packet is routed independently, regardless of any other packets that may have come before. HTTP/HTTPS is an application-layer protocol (off-topic here), and routers know nothing about that.
    – Ron Maupin
    Jun 24, 2020 at 17:25
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.
    – Ron Maupin
    Dec 17, 2020 at 18:37

1 Answer 1


Normally, routing is based on a packet's destination address. Some routers feature policy-based routing which you could use to route by application protocol, e.g. HTTP/S. However, you cannot route based on a (yet unknown) size of an application-layer reply.

Even if the router could detect the reply size, you cannot reroute a TCP connection once it has been established. Doing so would change the client address visible to the public server and break the TCP socket.

What you ask could be possible using an application-level proxy, but those are off-topic here for operating above the transport layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.