felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1685752 - in /felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal: ConfigMetaTypeProvider.java JettyConfig.java JettyService.java
Date Tue, 16 Jun 2015 10:02:23 GMT
Author: cziegeler
Date: Tue Jun 16 10:02:22 2015
New Revision: 1685752

URL: http://svn.apache.org/r1685752
Log:
FELIX-4908 : X-Forward Header support when running behind a proxy/load balancer. Apply patch
from Antonio Sanso

Modified:
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java?rev=1685752&r1=1685751&r2=1685752&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
(original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
Tue Jun 16 10:02:22 2015
@@ -242,6 +242,12 @@ class ConfigMetaTypeProvider implements
                 2147483647,
                 null, null,
                 bundle.getBundleContext().getProperty(JettyConfig.FELIX_JETTY_EXCLUDED_PROTOCOLS)));
+        
+        adList.add(new AttributeDefinitionImpl(JettyConfig.FELIX_PROXY_LOAD_BALANCER_CONNECTION_ENABLE,
+                "Enable Proxy/Load Balancer Connection",
+                "Whether or not the Proxy/Load Balancer Connection is enabled. Defaults to
false thus disabled.",
+                false,
+                bundle.getBundleContext().getProperty(JettyConfig.FELIX_PROXY_LOAD_BALANCER_CONNECTION_ENABLE)));
 
         return new ObjectClassDefinition()
         {

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java?rev=1685752&r1=1685751&r2=1685752&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
(original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
Tue Jun 16 10:02:22 2015
@@ -127,6 +127,9 @@ public final class JettyConfig
     /** Felix specific property to configure the excluded protocols */
     public static final String FELIX_JETTY_EXCLUDED_PROTOCOLS = "org.apache.felix.https.jetty.protocols.excluded";
 
+    /** Felix specific property to control whether to enable Proxy/Load Balancer Connection
*/
+    public static final String FELIX_PROXY_LOAD_BALANCER_CONNECTION_ENABLE = "org.apache.felix.proxy.load.balancer.connection.enable";
+    
     private static String validateContextPath(String ctxPath)
     {
         // undefined, empty, or root context path
@@ -359,6 +362,11 @@ public final class JettyConfig
         boolean useHttps = getBooleanProperty(FELIX_HTTPS_ENABLE, getBooleanProperty(OSCAR_HTTPS_ENABLE,
false));
         return useHttps && getHttpsPort() > 0;
     }
+    
+    public boolean isProxyLoadBalancerConnection()
+    {
+        return getBooleanProperty(FELIX_PROXY_LOAD_BALANCER_CONNECTION_ENABLE, false);
+    }
 
     public void reset()
     {

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1685752&r1=1685751&r2=1685752&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
(original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
Tue Jun 16 10:02:22 2015
@@ -47,6 +47,7 @@ import org.eclipse.jetty.http.HttpVersio
 import org.eclipse.jetty.security.HashLoginService;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.ConnectorStatistics;
+import org.eclipse.jetty.server.ForwardedRequestCustomizer;
 import org.eclipse.jetty.server.HttpConfiguration;
 import org.eclipse.jetty.server.HttpConnectionFactory;
 import org.eclipse.jetty.server.SecureRequestCustomizer;
@@ -317,6 +318,12 @@ public final class JettyService extends
         configureHttpConnectionFactory(connFactory);
         ServerConnector connector = new ServerConnector(server, connFactory);
         configureConnector(connector, this.config.getHttpPort());
+        
+        if (this.config.isProxyLoadBalancerConnection())
+        {
+            connFactory.getHttpConfiguration().addCustomizer(new ForwardedRequestCustomizer());
+        }
+        
         return startConnector(connector);
     }
 
@@ -329,7 +336,14 @@ public final class JettyService extends
         configureSslContextFactory(sslContextFactory);
 
         ServerConnector connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory,
HttpVersion.HTTP_1_1.toString()), connFactory);
-        connFactory.getHttpConfiguration().addCustomizer(new SecureRequestCustomizer());
+        HttpConfiguration httpConfiguration = connFactory.getHttpConfiguration();
+        httpConfiguration.addCustomizer(new SecureRequestCustomizer());
+        
+        if (this.config.isProxyLoadBalancerConnection())
+        {
+            httpConfiguration.addCustomizer(new ForwardedRequestCustomizer());
+        }
+        
         configureConnector(connector, this.config.getHttpsPort());
         return startConnector(connector);
     }



Mime
View raw message