Using single port for VPN and secure web server

Sometimes you need access your home network, to configure and checkup something, from cooperate office

Here’s HaProxy config

frontend 80-tcp-traffic
    bind *:80
    mode tcp
    use_backend HttpReverseProxy

frontend 443-tcp-traffic
    bind *:443
    mode tcp

    tcp-request inspect-delay 5s
    tcp-request content accept if { req_ssl_hello_type 1 }

    use_backend HttpsReverseProxy if { req_ssl_hello_type 1 }
    default_backend OpenVPN

backend HttpReverseProxy
    mode tcp
    server ReverseProxy80 Reverse_Proxy_IP:80 check

backend HttpsReverseProxy
    mode tcp
    server ReverseProxy443 Reverse_Proxy_IP:443 check

backend OpenVPN
    mode tcp
    server vpn OpenVPN_Server:443 check

Why should I do it like this?

If your hosting a website and you would like to host a your own personal OpenVPN server. Where would it come in handy, for example in an office, depending how well they configured their firewall. You can guarantee that port 443 using TCP protocol, or protocol that websites traffic work on.

If checks SSL connections, if detects incoming traffic that doesn’t show HTTPS or TLS/SSL connections type, it’s redirects to VPN server.

Leave a Comment