Last active
June 20, 2018 22:48
-
-
Save etiennepouliot/c2fff3de297ee2a9fec10c4ed34f80ec to your computer and use it in GitHub Desktop.
Haproxy configuration to share a port 80/443 with nginx (or Apache, etc) and SSH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh foo.example.com -p 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
log 127.0.0.1 local2 | |
chroot /var/lib/haproxy | |
pidfile /var/run/haproxy.pid | |
maxconn 4000 | |
user haproxy | |
group haproxy | |
daemon | |
# turn on stats unix socket | |
stats socket /var/lib/haproxy/stats | |
defaults | |
timeout connect 5000 | |
timeout client 50000 | |
timeout server 50000 | |
frontend main | |
mode tcp | |
bind 0.0.0.0:80 | |
tcp-request inspect-delay 5s | |
#find ssh signature | |
use_backend ssh if { payload(0,7) -m bin 5353482d322e30 } | |
default_backend webserver | |
backend ssh | |
mode tcp | |
timeout server 2h | |
timeout client 2h | |
server ssh-localhost 127.0.0.1:22 | |
backend webserver | |
mode tcp | |
server webserver-localhost 127.0.0.1:8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 127.0.0.1:8080; | |
.... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should also work with TLS/SSL, juste need to use tcp backend to a nginx/apache serving the certificate.