gnif / mod_rpaf

reverse proxy add forward module for Apache
199 stars 79 forks source link

RPAF_SetHostName On breaks proxying using mod_rewrite #24

Closed brablc closed 9 years ago

brablc commented 9 years ago

When requesting http://domain1.dev/domain2/test.html with the following configuration:

<VirtualHost *:80>
ServerName domain1.dev
RewriteEngine On
RewriteRule /domain2/(.*) http://domain2.dev/$1 [P]
</VirtualHost>

One would expect to get content of http://domain2.dev/test.html, but this would not work when rpaf is enabled and RPAF_SetHostName set to On. You would get http://domain1.dev/test.html - it seems like RPAF replaces the Host header from domain2.dev to domain1.dev in the proxied request.

Both domain1.dev and domain2.dev resolve to the same IP address.

gnif commented 9 years ago

Interesting, can you please provide some traffic dumps so I can reproduce the issue here.

brablc commented 9 years ago

The setup:

mkdir -p /var/www/domain1 && echo "WRONG" >$_/test.html
mkdir -p /var/www/domain2 && echo "OK" >$_/test.html
<VirtualHost *:80>
ServerName domain1.dev
RewriteEngine On
RewriteLogLevel 9
RewriteLog /var/log/apache2/rewrite.log
RewriteRule /domain2/(.*) http://domain2.dev/$1 [P]
DocumentRoot /var/www/domain1
</VirtualHost>

<VirtualHost *:80>
ServerName domain2.dev
DocumentRoot /var/www/domain2
</VirtualHost>

Test curl http://domain1.dev/domain2/test.html

127.0.0.1 - - [14/Oct/2015:22:45:53 +0200] [domain1.dev/sid#7fdc2cf82c78][rid#7fdc2d953040/initial] (2) init rewrite engine with requested uri /domain2/test.html
127.0.0.1 - - [14/Oct/2015:22:45:53 +0200] [domain1.dev/sid#7fdc2cf82c78][rid#7fdc2d953040/initial] (3) applying pattern '/domain2/(.*)' to uri '/domain2/test.html'
127.0.0.1 - - [14/Oct/2015:22:45:53 +0200] [domain1.dev/sid#7fdc2cf82c78][rid#7fdc2d953040/initial] (2) rewrite '/domain2/test.html' -> 'http://domain2.dev/test.html'
127.0.0.1 - - [14/Oct/2015:22:45:53 +0200] [domain1.dev/sid#7fdc2cf82c78][rid#7fdc2d953040/initial] (2) forcing proxy-throughput with http://domain2.dev/test.html
127.0.0.1 - - [14/Oct/2015:22:45:53 +0200] [domain1.dev/sid#7fdc2cf82c78][rid#7fdc2d953040/initial] (1) go-ahead with proxy request proxy:http://domain2.dev/test.html [OK]
127.0.0.1 - - [14/Oct/2015:22:46:32 +0200] [domain1.dev/sid#7fc5de794c78][rid#7fc5df15f010/initial] (2) init rewrite engine with requested uri /domain2/test.html
127.0.0.1 - - [14/Oct/2015:22:46:32 +0200] [domain1.dev/sid#7fc5de794c78][rid#7fc5df15f010/initial] (3) applying pattern '/domain2/(.*)' to uri '/domain2/test.html'
127.0.0.1 - - [14/Oct/2015:22:46:32 +0200] [domain1.dev/sid#7fc5de794c78][rid#7fc5df15f010/initial] (2) rewrite '/domain2/test.html' -> 'http://domain2.dev/test.html'
127.0.0.1 - - [14/Oct/2015:22:46:32 +0200] [domain1.dev/sid#7fc5de794c78][rid#7fc5df15f010/initial] (2) forcing proxy-throughput with http://domain2.dev/test.html
127.0.0.1 - - [14/Oct/2015:22:46:32 +0200] [domain1.dev/sid#7fc5de794c78][rid#7fc5df15f010/initial] (1) go-ahead with proxy request proxy:http://domain2.dev/test.html [OK]
127.0.0.1 - - [14/Oct/2015:22:46:32 +0200] [domain1.dev/sid#7fc5de794c78][rid#7fc5df15f010/initial] (2) init rewrite engine with requested uri /test.html
127.0.0.1 - - [14/Oct/2015:22:46:32 +0200] [domain1.dev/sid#7fc5de794c78][rid#7fc5df15f010/initial] (3) applying pattern '/domain2/(.*)' to uri '/test.html'
127.0.0.1 - - [14/Oct/2015:22:46:32 +0200] [domain1.dev/sid#7fc5de794c78][rid#7fc5df15f010/initial] (1) pass through /test.html
gnif commented 9 years ago

Please provide the rpaf comfig also

brablc commented 9 years ago
<IfModule mod_rpaf.c>
RPAFenable On
RPAFsethostname Off
RPAFproxy_ips 127.0.0.1 10.0.2.15
</IfModule>
gnif commented 9 years ago

This config is invalid for the current version of mod_rpaf, please confirm you are running a recent version.

brablc commented 9 years ago

OK, let's close this until I migrate to newer version. I do not have testing environment for this right now.