My goal is to write proxy, which will proxy all requests to the VPN. So, I've written the following configuration: <VirtualHost *:8121> RewriteEngine On ErrorLog logs/misc-error_log TransferLog logs/misc-access_log RewriteRule ^/(.*) http://%{HTTP_HOST}:8121/$1 [P] </VirtualHost> However, for some reason, it's not working as expected. It seems that it tries to resolve '%{HTTP_HOST}:8121' as host name. Browser answer is Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /. Reason: DNS lookup failure for: n01wmw202:8121 Log error contains the same entry [Sat Oct 04 07:34:34.123051 2014] [proxy:error] [pid 4004:tid 1260] [client 192.168.33.148:64292] AH00898: DNS lookup failure for: n01wmw202:8121 returned by / If I remove ':8121' everything is working as expected.
It also reproduces if i change it to RewriteRule ^/(.*) http://%{HTTP_HOST}:%{SERVER_PORT}/$1 [P]
Unless I missed something, your configuration matches: > Here are all possible substitution combinations and their meanings: > > Inside per-server configuration (httpd.conf) > for request ``GET /somepath/pathinfo'': > [...] > ^/somepath(.*) http://thishost/otherpath$1 [P] doesn't make sense, not supported at the end of https://httpd.apache.org/docs/2.4/en/mod/mod_rewrite.html#rewriterule. I tried your configuration with the trunk version. I also get a AH00898, but with another error message. If I change the port number in the RewriteRule to something different from the one in the VirtualHost, everything seems to work fine. So, I guess that "*:8121" in VirtualHost and '%{HTTP_HOST}:8121' in RewriteRule are the same, which is not supported as per doc. So closing as invalid. Feel free to re-open, if I misunderstood something.
Well, If if it not supported for now, is it possible to convert this into a feature request? It would be very handy to specify a port in case it is different from the virtual host configuration.
If the port is different, it seems to work, according to my testing. Look at the allowed configuration at the bottom of the link in comment 2. My understanding of the doc, and according to my tests, is that "thishost" mentioned in the doc means "the host name including its port". So *:8121 in the VirtualHost and '%{HTTP_HOST}:8121' in RewriteRule matches, and is not a supported configuration. But *:8121 in the VirtualHost and '%{HTTP_HOST}:8122' in RewriteRule shouldn't match and would refer to : > ^localpath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo via internal proxy in the doc. If you could try and confirm, I would update the doc to be more precise.
(and thx for your prompt feed-back on a 4 years old PR!)