vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

The DatagramSocketOptions in vertx.create DatagramSocket do not have setUseProxyProtocol and cannot be used through Channel. pipelin(). addLast (new HAProxyMessage Decoder)

Open yuchonghua opened this issue 8 months ago • 5 comments

Read me

Read this first before creating an issue:

  • do not use this issue tracker to ask questions, instead use one of these channels. Questions will likely be closed without notice.
  • you shall create a feature request only when it is general purpose enough.
  • make sure that the feature is not already

Describe the feature

vertx.createDatagramSocket udp UseProxyProtocol

Use cases

new DatagramSocketOptions().setUseProxyProtocol(false);

Contribution

Who should implement this feature ? are you volunteering for implementing this feature or do you know that is able and willing implement this feature ?

yuchonghua avatar Mar 27 '25 00:03 yuchonghua

does it make sense to use proxy for UDP packets ?

vietj avatar Mar 27 '25 08:03 vietj

does it make sense to use proxy for UDP packets ?

UDP packets need to be forwarded to internal network services for processing, which means that the UDP packets received by Vertx are forwarded through a load balancing device like nginx. We hope to directly attempt to reply to the sender to avoid rebroadcasting through nginx, but internal services can push data to the sender through NAT or other means

/ping @vietj

yuchonghua avatar Mar 27 '25 15:03 yuchonghua

do you have a reference about proxy protocol and UDP ?

vietj avatar Mar 27 '25 18:03 vietj

  1. HAProxy: UDP Proxy Protocol Configuration ​Requirements: HAProxy ​**≥ 2.3** (supports UDP and Proxy Protocol v2). ​Example Configuration:
# haproxy.cfg
global
  log /dev/log local0
  maxconn 4000
  # Enable PPv2 for UDP
  tune.ssl.default-dh-param 2048

defaults
  log global
  timeout connect 5s
  timeout client 30s
  timeout server 30s

# Frontend: Listen on UDP port with PPv2
frontend udp_frontend
  mode udp
  bind :514 udp  # Example: UDP port 514 (e.g., Syslog)
  default_backend udp_backend

# Backend: Forward to servers with PPv2 header
backend udp_backend
  mode udp
  server server1 192.168.1.100:514 send-proxy-v2  # Append PPv2 header
  1. Nginx: UDP Proxy Protocol Limitations ​Example for UDP(Reference):
# nginx.conf (example)
stream {
  server {
    listen 12345 udp;
    proxy_pass backend_server;
    proxy_protocol on;  
  }
}

yuchonghua avatar Mar 28 '25 00:03 yuchonghua

This is relevant for http3. I think we have proxy work done there already @vietj

zekronium avatar Mar 30 '25 13:03 zekronium