Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5412819CDC for ; Thu, 7 Apr 2016 11:51:26 +0000 (UTC) Received: (qmail 35123 invoked by uid 500); 7 Apr 2016 11:51:25 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 35083 invoked by uid 500); 7 Apr 2016 11:51:25 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 35074 invoked by uid 99); 7 Apr 2016 11:51:25 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Apr 2016 11:51:25 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 746272C1F5C for ; Thu, 7 Apr 2016 11:51:25 +0000 (UTC) Date: Thu, 7 Apr 2016 11:51:25 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CAMEL-9462) HTTP 1.1 Host header be dealt wrongly in proxy & load balancer MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-9462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15230126#comment-15230126 ] ASF GitHub Bot commented on CAMEL-9462: --------------------------------------- GitHub user erwelch opened a pull request: https://github.com/apache/camel/pull/935 CAMEL-9462 HTTP 1.1 Host header be dealt wrongly in proxy & load balancer You can merge this pull request into a Git repository by running: $ git pull https://github.com/erwelch/camel CAMEL-9462 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/camel/pull/935.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #935 ---- commit dfc6ee1098745518ca5db5aefef9f5b0f19b934d Author: Edward Welch Date: 2016-04-07T11:48:16Z Adding a new endpoint property to the HttpCommonEndpoint which allows preserving the Host header in reverse proxy applications, this class is ued by the Http, Http4, and Jetty producers. Updated the HttpProducer (Jetty/HTTP4) to set the Host header when this flag is enabled. The older HTTP component does not readily let us override the Host header, this component will not support this parameter Updated the Integration Test to validate the behavior for both when the new parameter is set, and unset. ---- > HTTP 1.1 Host header be dealt wrongly in proxy & load balancer > -------------------------------------------------------------- > > Key: CAMEL-9462 > URL: https://issues.apache.org/jira/browse/CAMEL-9462 > Project: Camel > Issue Type: Bug > Components: camel-http, camel-http4 > Affects Versions: 2.9.5, 2.10.3, 2.11.0 > Reporter: Ian Hu > Fix For: 2.17.1, 2.18.0 > > > I have wrote code below make camel as a load balancer, but camel-http4(and the camel-http, etc) deal the http header Host wrongly, it replace the Host header with the host name of the backend of balancer, that make the backend generate the wrong link. > > {code:title=Main.java|borderStyle=solid} > import org.apache.camel.impl.DefaultCamelContext; > import org.apache.camel.model.RouteDefinition; > public class Main { > public static void main(String[] args) throws Exception { > DefaultCamelContext context = new DefaultCamelContext(); > RouteDefinition route = new RouteDefinition(); > route.from("jetty:http://0.0.0.0:8080/?matchOnUriPrefix=true") > .loadBalance().roundRobin() > .to("http4://127.0.0.1:8081/?bridgeEndpoint=true&throwExceptionOnFailure=false") > .to("http4://127.0.0.1:8082/?bridgeEndpoint=true&throwExceptionOnFailure=false"); > // > context.addRouteDefinition(route); > context.start(); > } > } > {code} > I have view the code and found a fix of [https://issues.apache.org/jira/browse/CAMEL-5757](See the commit), it's commits simply removed the host header [https://fisheye6.atlassian.com/browse/camel-git/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java?hb=true#to106]. and I really do not think it should be dealt like that. > Some backend will use the Host header to generate link, and when the Host header removed and then it be set to the backend's host, the backend got the wrong Host, and generate the wrong link. > I expect the link should be http://localhost:8080/web but it generate http://127.0.0.1:8081/web or http://127.0.0.1:8082/web when I view the page with the url http://localhost:8080 -- This message was sent by Atlassian JIRA (v6.3.4#6332)