Emil CHERICHES

Emil CHERICHES

OpenVPN on 443

October 4, 2023 Emil C
No Comments

SSL VPN?

Lately I’ve been working on a project where security is very important. In order to connect to the hosting provider I needed to use a specific VPN provided by FortiNet. What’s interesting about this VPN solution is that apparently it uses HTTPS. this gave me the idea to look for a solution like this for me as well, but I did not want to rent another public IP just for a VPN.

On some articles I read that OpenVPN would be capable to “share” the port 443 with the web server/reverse proxy, etc. Truth be told it’s actually OpenVPN listening on 443 and forwarding all the requests that it does not understand to the web server wich is actually made to listen on another port.

And it works fine, after setting it up Qualy’s SSL test is still validating my web server as A+.
The next step is to test the VPN solution from behind a very restrictive firewall. I hope to be able to test it as one of my clients is behind such a firewall and I plan to pay him a visit.

And here’s the detail on how to obtain this:

I’m running my reverse proxy on Debian 12 bookworm. Installing OpenVPN is one command away:

apt install openvpn

Certificates

I prefer to keep my vpn certificates and private keys on another computer than the vpn server. This time I even generated them on this computer. To do this I use this specific folder from easy-rsa-old repository.

First you need to edit the vars file to match your certificate names. Then load theese variables and generate the cetificates:

source ./vars
./clean-all
./build-ca
./build-key-server servername
./build-key client1
./build-key client2
etc.

./build-dh

Server config

port 443
port-share 127.0.0.1 1443

proto tcp
proto tcp6
dev tun

ca ca.crt
cert servername.crt
key servername.key

topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist /var/log/openvpn/ipp.txt
push "route 192.168.100.0 255.255.255.0"
push "redirect-gateway def1 bypass-dhcp"
;push "dhcp-option DNS 208.67.222.222"
;push "dhcp-option DNS 208.67.220.220"

keepalive 10 120
tls-auth ta.key 0 # This file is secret

cipher  AES-256-GCM

persist-key
persist-tun

status /var/log/openvpn/openvpn-status.log

verb 3

copy ca.crt servername.crt and servername.key from the machine the certificate was generated.
Also to generate ta.key you should run:

openvpn --genkey tls-auth ta.key

Save this file’s contents for the client config. My reverse proxy is haproxy. In my config file I had to change something like:

bind :1443 v4v6 ssl crt /etc/haproxy/haproxy.pem alpn h2,http/1.1
bind :::1443 v4v6 ssl crt /etc/haproxy/haproxy.pem alpn h2,http/1.1

Then start/restart daemons:

systemctl restart haproxy.service
systemctl enable --now openvpn@servername.service

Then to se what happens

journalctl -fu -n 100 openvpn@servername

Client config

client

dev tun

proto tcp
proto tcp6

remote servername.com 443

resolv-retry infinite
nobind
persist-key
persist-tun

<ca>
-----BEGIN CERTIFICATE-----
# here we put the contents of ca.crt
-----END CERTIFICATE-----
</ca>

<cert>
-----BEGIN CERTIFICATE-----
# contents of client1.crt
-----END CERTIFICATE-----
</cert>

<key>
-----BEGIN PRIVATE KEY-----
# contents of client1.key
-----END PRIVATE KEY-----
</key>

remote-cert-tls server
key-direction 1
tls-cipher "DEFAULT:@SECLEVEL=0"

<tls-auth>
-----BEGIN OpenVPN Static key V1-----
# contents of ta.key
-----END OpenVPN Static key V1-----
</tls-auth>

cipher AES-256-GCM

verb 3

linux security HTTPSOpenVPNVPN
Previous Post

DokuWiki a simple solution to sorting documentation

Next Post

The anatomy of a smart bulb

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts
  • Debian on BTRFS with subvolumes
  • NixOS TIP: OTP in Gnome login screen
  • Arch to Manjaro – the dirty way
  • The anatomy of a smart bulb
  • OpenVPN on 443
Categories
  • from the web
  • just blog
  • linux
    • Debian
    • NixOS
  • phones
  • Phones & Tablets
  • programing
  • security
  • Smart Home
  • Tips & Tricks
  • Uncategorized
  • Web development
  • Windows
Blogroll
  • cheriches.fr
Subscribe by Email
Recent Posts
  • Debian on BTRFS with subvolumes
  • NixOS TIP: OTP in Gnome login screen
  • Arch to Manjaro – the dirty way
  • The anatomy of a smart bulb
  • OpenVPN on 443
Categories
  • from the web (3)
  • just blog (1)
  • linux (20)
    • Debian (1)
    • NixOS (1)
  • phones (1)
  • Phones & Tablets (2)
  • programing (1)
  • security (2)
  • Smart Home (1)
  • Tips & Tricks (16)
  • Uncategorized (1)
  • Web development (1)
  • Windows (1)
Blogroll
  • cheriches.fr
Tags cloud
adb ADS aircrack-ng Android Apache apt-get Arch BTRFS CentOS Chrome Cluster CSS debian Docker Firefox firmware flashing GNOME Google Authenticator High Availability HTTPS javascript KVM linux Manjaro MySQL OpenBeken OpenBK7231T OpenVPN OTP php piwik Postfix Proxy_ARP release RHEL Samba ssh Tuya ubuntu UEFI VPN VRRP windows Youtube
Recent Comments
  • Greg M on The anatomy of a smart bulb
  • The anatomy of a smart bulb #LED @EmilsBits « Adafruit Industries – Makers, hackers, artists, designers and engineers! on The anatomy of a smart bulb
  • Emil C on The anatomy of a smart bulb
  • David Brower on The anatomy of a smart bulb
  • 智能灯泡的解剖 - 偏执的码农 on The anatomy of a smart bulb
Proudly powered by WordPress | Theme: Fmi by Forrss.
Manage Cookie Consent
We use cookies to optimize our website and our service.
Functional cookies Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}