My end goal is to set up a Nginx that is only accessible through OpenVPN server. the clients that want to acess the website with address X.X.X.X will access it via the VPN tunnel, all other traffic will route to default gateway as usual.
server.conf
port 1194
proto udp
dev tun
sndbuf 0
rcvbuf 0
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-auth ta.key 0
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
cipher AES-256-CBC
comp-lzo
user nobody
group nogroup
persist-key
pe[b][/b]rsist-tun
status openvpn-status.log
verb 3
crl-verify crl.pem
client.conf
client
dev tun
proto udp
sndbuf 0
rcvbuf 0
remote 35.156.85.171 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA512
cipher AES-256-CBC
comp-lzo
setenv opt block-outside-dns
key-direction 1
But I noticed that for some strange reason, all traffic
besides the target server goes through the VPN tunnel once its up.
route table without VPN client:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.138 0.0.0.0 UG 102 0 0 enp1s0
10.0.0.0 0.0.0.0 255.255.255.0 U 102 0 0 enp1s0
WITH VPN client:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
0.0.0.0 10.0.0.138 0.0.0.0 UG 102 0 0 enp1s0
10.0.0.0 0.0.0.0 255.255.255.0 U 102 0 0 enp1s0
10.8.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
35.156.85.171 10.0.0.138 255.255.255.255 UGH 0 0 0 enp1s0
128.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0