Bug 61010 - ProxyPreserveHost Not working as documented
Summary: ProxyPreserveHost Not working as documented
Status: NEEDINFO
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy (show other bugs)
Version: 2.4.6
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-19 22:39 UTC by gabe
Modified: 2017-04-19 23:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gabe 2017-04-19 22:39:19 UTC
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost

Says:

When enabled, this option will pass the Host: line from the incoming request to the proxied host, instead of the hostname specified in the ProxyPass line.

However, when I setup a ProxyPass:

  <Location /en_US>
    ProxyPass "http://othersite.com"
  </Location>

The othersite.com was receiving mysite.com as the HOST header.
Adding ProxyPreserveHost Off or ProxyPreserveHost On made no difference.
When I changed the config to

  <Location /en_US>
    RequestHeader set Host othersite.com
    ProxyPass "http://othersite.com"
  </Location>

It worked perfectly.
Seems like a bug. Am I misunderstanding?


httpd -V
Server version: Apache/2.4.6 (Red Hat Enterprise Linux)
Server built:   Sep 17 2015 09:06:30
Server's Module Magic Number: 20120211:24
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

I'll try a newer version to see if that makes any difference.
Comment 1 Jacob Champion 2017-04-19 23:06:43 UTC
Doesn't seem to be reproducible with 2.4.25, at the very least. My test config:

  <Location /proxied>
    # backend sees 'Host: localhost:9090'
    ProxyPass "http://localhost:9090"
  </Location>

Let us know whether your tests with a newer version work as expected.