Created attachment 31775 [details] patch: copy source_address in ap_proxy_connect_to_backend When I use ProxySourceAddress together with mod_proxy_connect to proxy https connections I get occasional error messages in error_log like: [proxy:error] [pid 8703:tid 139730268100352] (98)Address already in use: [client 192.168.1.192:50519] AH00938: CONNECT: failed to bind socket to local address and the ProxySourceAddress for that request is ignored. The cause seems to be that ap_proxy_connect_to_backend (called by mod_proxy_connect) calls apr_socket_bind with conf->source_address directly passed as argument, so the selected local port is stored in conf->source_address and used in subsequent binds. This fails if that port is still in use. The function ap_proxy_connect_backend (used by mod_proxy_http) makes a copy of conf->source_address before passing it to apr_socket_bind, and when I tried that for ap_proxy_connect_to_backend the problem disappeared (see patch).
We experience the same issue with Apache 2.4.10. When this will be fixed in Apache 2.4, please?
As a workaround for this bug, you can add the following to your Apache config: MaxRequestsPerChild 1 This will create a new process for each request, with a fresh conf->source_address. Of course this will hurt performance!
I have used Arne's patch posted previously with the bug report and it seems to be working fine. thanks Arne! Thanks Robert for workaround too. I hope, once this bug will be solved officially in some next release of Apache...
Thanks, committed in r1703902.
Backport proposed to 2.4.x in r1703903.
This is part of 2.4.17