OpenVPN Client alongside Apache HTTPD

What is the best way to set OpenVPN Connect on the same server where Apache HTTP Deeamon is running.

I have multiple domains hosted on that server and I want to configure OpenVPN on vpn.example.com for client connect.

I tried to setup proxy on Apache so that https://vpn.example.com will point to localhost:943 but it won’t work 🙁

Answer

OpenVPN configuration has a port-share directive. It allows OpenVPN to listen on port 443. It detects the type of traffic. If it’s VPN traffic, proccesses it. If it’s http, redirects it to a designated server.

From OpenVPN documentation:

–port-share host port [dir]
When run in TCP server mode, share the OpenVPN port with another application, such as an HTTPS server. If
OpenVPN senses a connection to its port which is using a non-OpenVPN
protocol, it will proxy the connection to the server at host:port.
Currently only designed to work with HTTP/HTTPS, though it would be
theoretically possible to extend to other protocols such as ssh. dir
specifies an optional directory where a temporary file with name N
containing content C will be dynamically generated for each proxy
connection, where N is the source IP:port of the client connection and
C is the source IP:port of the connection to the proxy receiver. This
directory can be used as a dictionary by the proxy receiver to
determine the origin of the connection. Each generated file will be
automatically deleted when the proxied connection is torn down.

Attribution
Source : Link , Question Author : Milos Miskone Sretin , Answer Author : Mike B

Leave a Comment