Use haproxy to run SSH and VMess on the same port
-
Delay incoming connections for a period of time -
Judge whether the client has sent the payload before the end of the time -
Judge whether payload is SSH protocol -
If it is not the SSH protocol, it will be sent to the v2ray backend -
If it is the SSH protocol, or the client does not send any information before timeout, go to openssh
global log /dev/log local2 pidfile /run/haproxy.pid maxconn 1000 defaults timeout http-request 30s timeout queue 30s timeout connect 10s timeout client 15m timeout client-fin 15m timeout server 15m timeout http-keep-alive 10s timeout check 10s timeout tunnel 12h frontend main mode tcp bind *:11111 tcp-request inspect-delay 100ms tcp-request content accept if { req.payload(0,3) -m found } Tcp request content accept if WAIT_END # Delay request Acl is_ssh req. payload (0,3) - m bin 535348 # Judge whether it is SSH payload Acl have_payload req. payload (0,3) - m found # Judge whether there is payload Use_backend ssh if is_ssh # If SSH is forwarded to openssh Use_backend v2ray if have_payload # If it is not SSH and there is payload, it will be forwarded to v2ray Default_backend ssh # Forward other information to openssh backend ssh mode tcp server sshd 127.0.0.1:22 backend v2ray mode tcp server v2ray 127.0.0.1:8989