Skip to content

mod_http3: Select an IP-based virtual host by the destination address - #1070

Open
arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:fix/httpd-h3-ip-vhost
Open

arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:fix/httpd-h3-ip-vhost

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

h3_synth_conn() sets c->local_addr to 0.0.0.0, so ap_update_vhost_given_ip() never matches an IP-based virtual host: an HTTP/3 request to the address of one IP-based virtual host is served by another, and %A logs 0.0.0.0. With Listen 18743, <VirtualHost 127.0.0.1:18743> (docs1) defined before <VirtualHost 127.0.0.2:18743> (docs2), both with h3, a request to 127.0.0.2 gets docs2 over TCP but docs1 over HTTP/3 on trunk; with this change it gets docs2, and %A logs 127.0.0.2:18743.

The QUIC engine already keeps the connection's path, whose local side is the address the client sent to (IP_PKTINFO/IPV6_PKTINFO on Linux, the bound address elsewhere). This adds h3q_engine_local_addr(), a twin of h3q_engine_peer_addr(), and uses it for c->local_addr. The port stays the TCP port of the HTTP/3 host, so an H3Port of its own still matches <VirtualHost addr:port>.

Not addressed here: an address that no IP-based virtual host names still reaches the first HTTP/3 virtual host, where TCP falls back to the main server. The natural close is the 421 for a virtual host whose TLS setup differs from the HTTP/3 one, which test_h3_103_04 already asks for; test_h3_018_02 records this case as a known bug. That touches how mod_http3 relates to mod_ssl, so I would rather work it out with you.

The OpenSSL QUIC backend will need its own h3q_engine_local_addr(); its sources are not in trunk yet (#1038). With #1069, several specific Listen addresses on a port leave HTTP/3 off, so IP-based HTTP/3 virtual hosts on different addresses use a wildcard Listen, which is the case this fixes.

Tests: test_h3_018_01 fails on trunk ("127.0.0.2 over HTTP/3 served by test1") and passes with this change. No new failures in the rest of modules/http3 (test_003_03 and test_106_01/02 fail at teardown on trunk as well; test_016, 203, 204 and 205 need aioquic, which I do not have locally). Built like the CI mod_http3 job, 0 warnings. A changes-entries file is included, there are no new log messages, and mod_http3 is trunk-only and unreleased, so this is not a security release issue.

@jfclere would you take a look?

h3_synth_conn() set c->local_addr to 0.0.0.0, which no IP-based virtual
host matches, so an HTTP/3 request to the address of one IP-based
virtual host was served by another, and %A logged 0.0.0.0.

Take the local address from the connection's network path, the address
the client sent to. Keep the TCP port of the HTTP/3 host, so that an
H3Port of its own still matches <VirtualHost addr:port>.

An address that no IP-based virtual host names still reaches the first
HTTP/3 virtual host; test_h3_018_02 records that as a known bug.

* modules/http3/quic/h3q.c, modules/http3/include/quic/h3q.h
  (h3q_engine_local_addr): New.
* modules/http3/h3_request.c (sockaddr_resolve, local_addr_resolve): New,
  from peer_addr_resolve.
  (h3_synth_conn): Set the local address from the connection's path.
* test/modules/http3/test_018_ip_vhost.py: New.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant