Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
Tutorials and FAQs
»
Tutorial 2024/06: HAProxy + Let's Encrypt Wildcard Certificates + 100% A+ Rating
« previous
next »
Print
Pages:
1
...
45
46
[
47
]
Author
Topic: Tutorial 2024/06: HAProxy + Let's Encrypt Wildcard Certificates + 100% A+ Rating (Read 394702 times)
braveworm
Newbie
Posts: 1
Karma: 0
Re: Tutorial 2024/06: HAProxy + Let's Encrypt Wildcard Certificates + 100% A+ Rating
«
Reply #690 on:
November 10, 2024, 07:19:58 am »
Any idea how to setup the VPN_redirect_rule as shown in the P000_001_Schematic?
I wanted to have openvpn and the https sites on the same port but can't figure out the rules and conditions.
Logged
stefan21
Full Member
Posts: 103
Karma: 10
Re: Tutorial 2024/06: HAProxy + Let's Encrypt Wildcard Certificates + 100% A+ Rating
«
Reply #691 on:
November 21, 2024, 10:24:52 am »
There are a lot of countries or even more and more hotels, where only tcp 80 and 443 are opened in their wifi's or LAN's.
Therefore I'm also highly interested how to configure hyproxy to seperate openvpn traffic from webtraffic. Googling around brings up this:
https://community.openvpn.net/openvpn/ticket/1352
" HAProxy is perfectly capable of proxying and load balancing OpenVPN in TCP mode, and to share a single listening port with OpenVPN and HTTPS sites. I have used this configuration for years.
To distinguish OpenVPN traffic from TLS traffic, use the following combination HAProxy ACL conditions in a HAProxy frontend
!{ req.ssl_hello_type 1 } !{ req.len 0 }
To distinguish SSH traffic from TLS traffic, use the following combination of HAProxy ACL conditions in a HAProxy frontend:
!{ req.ssl_hello_type 1 } { req.len 0 }
A HAProxy backend can be used to load balance multiple servers. Use TCP mode.
A barebone example configuration is given here:
https://gist.github.com/zukka77/a5ddb8d81ef9a82e2ff797e3a578c97e
Furthemore, PROXY protocol is protocol agnostic, and could therefore perfectly well be implemented in OpenVPN (Community version). Read more here:
https://www.haproxy.com/blog/haproxy/proxy-protocol/
PROXY protocol support in OpenVPN would be very welcome, since it will allow OpenVPN servers to know the real IP addresses of connecting clients."
Further more:
https://gist.github.com/zukka77/a5ddb8d81ef9a82e2ff797e3a578c97e
"frontend ssl
mode tcp
bind 0.0.0.0:443 name frontend-ssl
option tcplog
log global
tcp-request inspect-delay 3s
tcp-request content accept if { req.ssl_hello_type 1 }
use_backend main-ssl if { req.ssl_hello_type 1 }
use_backend ssh if !{ req.ssl_hello_type 1 } { payload(0,7) -m bin 5353482d322e30 }
use_backend openvpn if !{ req.ssl_hello_type 1 } !{ req.len 0 }
use_backend ssh if !{ req.ssl_hello_type 1 } { req.len 0 }
backend main-ssl
mode tcp
server main-ssl 127.0.0.1:8443
backend openvpn
mode tcp
server openvpn-localhost 127.0.0.1:1194
backend ssh
mode tcp
server ssh-localhost 127.0.0.1:22
"
Let's try together to figure out how this can be translated in OPNsense haproxy. As pre-requisite a openvpn server is running configured to listen on port 1194 and ready to connect to roadwarriors.
In haproxy:
1. I assume it has to be a condition created including !{ req.ssl_hello_type 1 } !{ req.len 0 }
2. a rule is needed which includes the condition and directs the traffic to the vpn server via the vpn backend.
3. a real openvpn server has to be setup
4. a backend vpn is needed
As the SNI_frontend sends most of its traffic to SSL_backend, has this to be integratet in the SNI_frontend or is a new i.e. VPN_frontend needed?
At this point I need help to step further. How exactly has this to be setup? Where are the gurus to get this on the way? IMVHO a lot of people would appreciate a solution.
regards,
stefan
Logged
stefan21
Full Member
Posts: 103
Karma: 10
Re: Tutorial 2024/06: HAProxy + Let's Encrypt Wildcard Certificates + 100% A+ Rating
«
Reply #692 on:
November 21, 2024, 04:16:37 pm »
Here's another solution:
https://www.reddit.com/r/selfhosted/comments/i0iq4g/guide_haproxy_with_openvpn/
"global
log /dev/log local0
log /dev/log local1 notice
tune.ssl.default-dh-param 2048
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy
daemon
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5s
timeout client 50s
timeout server 50s
frontend http
bind :80
mode http
option http-keep-alive
option forwardfor
timeout client 30s
# Redirect everything to https
redirect scheme https code 301 if !{ ssl_fc }
frontend TLS_passthrough
bind :443
mode tcp
option tcplog
tcp-request inspect-delay 5s
tcp-request content accept if { req_ssl_hello_type 1 } or !{ req_ssl_hello_type 1 }
# Change this to your domain
use_backend tcp_to_https if { req_ssl_sni -m end .yourdomain.tld }
default_backend openvpn
acl http req.ssl_ver gt 0
backend tcp_to_https
mode tcp
timeout connect 30s
timeout server 30s
server https 127.0.0.1:8443
frontend https
bind :8443 ssl crt-list /etc/ssl/haproxy.certlist
mode http
option http-keep-alive
option forwardfor
timeout client 30s
acl acl_guacamole hdr_beg(host) -i guacamole
acl acl_plex hdr_beg(host) -i plex
use_backend guacamole if acl_guacamole
use_backend plex if acl_plex
backend openvpn
mode tcp
timeout connect 30s
timeout server 30s
retries 3
server openvpn 192.168.100.218:443
backend plex
mode http
balance source
stick-table type ip size 50k expire 30m
stick on src
timeout connect 30s
timeout server 30s
http-reuse never
server plex 192.168.100.212:32400
backend guacamole
mode http
balance source
stick-table type ip size 50k expire 30m
stick on src
timeout connect 30s
timeout server 30s
http-reuse never
server guacamole 192.168.100.201:8084
"
How to translate this to OPNsense??? I tried for a few days, but it's beyond my knowledge.
Logged
Print
Pages:
1
...
45
46
[
47
]
« previous
next »
OPNsense Forum
»
English Forums
»
Tutorials and FAQs
»
Tutorial 2024/06: HAProxy + Let's Encrypt Wildcard Certificates + 100% A+ Rating