Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option enabling the support for the HA PROXY protocol #35470

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
* Holds configuration related with proxy addressing forward.
*/
public interface ProxyConfig {

/**
* Set whether the server should use the HA {@code PROXY} protocol when serving requests from behind a proxy.
* (see the <a href="https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt">PROXY Protocol</a>).
* When set to {@code true}, the remote address returned will be the one from the actual connecting client.
* If it is set to {@code false} (default), the remote address returned will be the one from the proxy.
*/
@WithDefault("false")
boolean useProxyProtocol();

/**
* If this is true then the address, scheme etc. will be set from headers forwarded by the proxy server, such as
* {@code X-Forwarded-For}. This should only be set if you are behind a proxy that sets these headers.
Expand Down Expand Up @@ -70,7 +80,7 @@ public interface ProxyConfig {
* The trusted proxy address should be specified as the IP address (IPv4 or IPv6), hostname or Classless Inter-Domain
* Routing (CIDR) notation. Please note that Quarkus needs to perform DNS lookup for all hostnames during the request.
* For that reason, using hostnames is not recommended.
*
* <p>
* Examples of a socket address in the form of `host` or `host:port`:
*
* <ul>
Expand All @@ -81,15 +91,15 @@ public interface ProxyConfig {
* <li>`localhost`</li>
* <li>`localhost:8084`</li>
* </ul>
*
* <p>
* Examples of a CIDR notation:
*
* <ul>
* <li>`::/128`</li>
* <li>`::/0`</li>
* <li>`127.0.0.0/8`</li>
* </ul>
*
* <p>
* Please bear in mind that IPv4 CIDR won't match request sent from the IPv6 address and the other way around.
*/
Optional<List<@WithConverter(TrustedProxyCheckPartConverter.class) TrustedProxyCheckPart>> trustedProxies();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ public static void applyCommonOptions(HttpServerOptions httpServerOptions,
}
httpServerOptions.setInitialSettings(settings);
}

httpServerOptions.setUseProxyProtocol(httpConfiguration.proxy().useProxyProtocol());
}

public static void applyCommonOptionsForManagementInterface(HttpServerOptions options,
Expand All @@ -299,6 +301,8 @@ public static void applyCommonOptionsForManagementInterface(HttpServerOptions op
}
options.setDecompressionSupported(buildTimeConfig.enableDecompression());
options.setHandle100ContinueAutomatically(httpConfiguration.handle100ContinueAutomatically());

options.setUseProxyProtocol(httpConfiguration.proxy().useProxyProtocol());
}

private static KeyStoreOptions createKeyStoreOptions(Path path, String password, Optional<String> fileType,
Expand Down