Skip to content

Commit

Permalink
Add ForwardedRequestCustomizer (#3407)
Browse files Browse the repository at this point in the history
This allows jetty to correctly handle x-forwarded-* headers.

```
$ curl -H "x-forwarded-proto: https" -H "x-forwarded-host: example.com" -I http://localhost:10000
HTTP/1.1 302 Found
Date: Mon, 06 Feb 2023 02:41:34 GMT
Location: https://example.com/ide/
Content-Length: 0
Server: Jetty(11.0.13)
```
  • Loading branch information
devinrsmith authored Feb 6, 2023
1 parent e133c81 commit 62e8113
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.server.ForwardedRequestCustomizer;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.SecureRequestCustomizer;
Expand Down Expand Up @@ -224,6 +225,7 @@ public int getPort() {
private static ServerConnector createConnector(Server server, JettyConfig config) {
// https://www.eclipse.org/jetty/documentation/jetty-11/programming-guide/index.html#pg-server-http-connector-protocol-http2-tls
final HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.addCustomizer(new ForwardedRequestCustomizer());
final HttpConnectionFactory http11 = config.http1OrDefault() ? new HttpConnectionFactory(httpConfig) : null;
final ServerConnector serverConnector;
if (config.ssl().isPresent()) {
Expand Down

0 comments on commit 62e8113

Please sign in to comment.