Re: ProxyPass option mapping=servlet hurts mod_rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Yann

Anyway, could you please try the attached patch and see if it works for you?

I have applied your patch to my httpd-2.4.52 and created two test cases.
One with a simple RewriteRule and a second one using a RewriteMap.
Both are working fine. :-)

Test logs attached: mod_rewrite_vs_proxy_pre_trans-v2_test_log.txt

Thank you for the very quick response!
Regards,
Hendrik

--
----------------------------------------------------------
Hendrik Harms
mail: hendrik.harms@xxxxxxxxx
Test-Setup:

## Both test cases:
  httpd-2.4.52 with patch mod_rewrite_vs_proxy_pre_trans-v2.diff

  Hostname:  example.org

  ProxyPass  /alpha  http://server1.localnet:8080/alpha
  ProxyPass  /beta   http://server2.localnet:8080/beta  mapping=servlet


## First test case: "simple RewriteRule"
  RewriteRule "^/alpha" - [F]
  RewriteRule "^/beta"  - [F]

# log extract
# https://example.org/alpha/anypath/
[proxy:trace2] mod_proxy.c(884): AH03461: attempting to match URI path '/alpha/anypath/' against prefix '/beta' for proxying
[rewrite:trace2] mod_rewrite.c(480): .... init rewrite engine with requested uri /alpha/anypath/. Original filename = n/a
[rewrite:trace3] mod_rewrite.c(480): .... applying pattern '^/alpha' to uri '/alpha/anypath/'
[rewrite:trace2] mod_rewrite.c(480): .... forcing responsecode 403 for /alpha/anypath/

# log extract
# https://example.org/beta/anypath/
[proxy:trace2] mod_proxy.c(884): AH03461: attempting to match URI path '/beta/anypath/' against prefix '/beta' for proxying
[proxy:trace1] mod_proxy.c(986): AH10248: Servlet path '/beta/anypath/' (/beta/anypath/) matches proxy handler 'proxy:http://server2.localnet:8080/beta/anypath/'
[rewrite:trace2] mod_rewrite.c(480): .... init rewrite engine with requested uri /beta/anypath/. Original filename = proxy:http://server2.localnet:8080/beta/anypath/
[rewrite:trace3] mod_rewrite.c(480): .... applying pattern '^/alpha' to uri '/beta/anypath/'
[rewrite:trace3] mod_rewrite.c(480): .... applying pattern '^/beta' to uri '/beta/anypath/'
[rewrite:trace2] mod_rewrite.c(480): .... forcing responsecode 403 for /beta/anypath/



## Second test case using RewriteMap to set a maintanance page covering the backend.
## We could set this maintanance page without restarting the httpd server by using
## a RewriteMap :-)

# map-maintain.conf
  alpha  /cover/503.shtml
  beta   /cover/503.shtml

# httpd.conf e.g. extra/httpd-default.conf
  RewriteMap   maintain txt:conf/map-maintain.conf
  RewriteRule  ^/([^/]+)  ${maintain:$1|%{REQUEST_URI}} [NC,PT]

# log extract 
# https://example.org/alpha/anypath/
[proxy:trace2] mod_proxy.c(884): AH03461: attempting to match URI path '/alpha/anypath/' against prefix '/beta' for proxying
[rewrite:trace2] mod_rewrite.c(480): .... init rewrite engine with requested uri /alpha/anypath/. Original filename = n/a
[rewrite:trace3] mod_rewrite.c(480): .... applying pattern '^/([^/]+)' to uri '/alpha/anypath/'
[rewrite:trace6] mod_rewrite.c(480): .... cache lookup FAILED, forcing new map lookup
[rewrite:trace5] mod_rewrite.c(480): .... map lookup OK: map=maintain[txt] key=alpha -> val=/cover/503.shtml
[rewrite:trace2] mod_rewrite.c(480): .... rewrite '/alpha/anypath/' -> '/cover/503.shtml'
[rewrite:trace2] mod_rewrite.c(480): .... forcing '/cover/503.shtml' to get passed through to next API URI-to-filename handler


# log extract
# https://example.org/beta/anypath/
[proxy:trace2] mod_proxy.c(884): AH03461: attempting to match URI path '/beta/anypath/' against prefix '/beta' for proxying
[proxy:trace1] mod_proxy.c(986): AH10248: Servlet path '/beta/anypath/' (/beta/anypath/) matches proxy handler 'proxy:http://server2.localnet:8080/beta/anypath/'
[rewrite:trace2] mod_rewrite.c(480): .... init rewrite engine with requested uri /beta/anypath/. Original filename = proxy:http://server2.localnet:8080/beta/anypath/
[rewrite:trace3] mod_rewrite.c(480): .... applying pattern '^/([^/]+)' to uri '/beta/anypath/'
[rewrite:trace6] mod_rewrite.c(480): .... cache lookup FAILED, forcing new map lookup
[rewrite:trace5] mod_rewrite.c(480): .... map lookup OK: map=maintain[txt] key=beta -> val=/cover/503.shtml
[rewrite:trace2] mod_rewrite.c(480): .... rewrite '/beta/anypath/' -> '/cover/503.shtml'
[rewrite:trace2] mod_rewrite.c(480): .... forcing '/cover/503.shtml' to get passed through to next API URI-to-filename handler


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux