3

I have a site on my local ubuntu dev box with some mod rewrite rules, which we are attempting to use to force google and other bots to index the correct page, rather than our ajax snippets as they have been doing. Although the rules are a bit longer that the snippet below, by disabling everything a section at a time, I find that even the most basic rewrite fails on the production server, but works fine on dev, even handling load testing with 14k requests via cUrl, no problem. We are using rewrite because proxypass doesn't work inside an <if>, and can't work based on %{QUERY_STRING}.

ProxyPass we were using before:

ProxyPreserveHost on
ProxyPass ajp://127.0.0.1:8009/other/view retry=0
ProxyPassReverse ajp://127.0.0.1:8009/request/view

The simple rewrite that causes 0.3 second mod_proxy request on dev to take upwards of 30 seconds on production:

RewriteRule ^(.*)(/request/view) ajp://localhost:8009/other/view [P]

Both servers are ubuntu and use the same version of apache:

Server version: Apache/2.4.52 (Ubuntu)
Server built:   2022-06-14T12:30:21

Both use LogLevel warn

I have used diff to verify that both files contain identical rewrite rules. I have checked that they both load the same mods (the dev box does load one mod that is not on prod, fcgid, but we are not using cgi anyways). The only thing of note we can think of, is that dev is http, and prod is https. This problem is immediate on loading the above rewrite condition and rule, and evaporates reverting to the ProxyPass directive - it is not tomcat9 based.

I need help on the next steps in troubleshooting, thanks.

sgc
  • 41
  • 5

1 Answers1

1

I never found out why this happened, but I did determine it was due to an error in the [P] flag (mod_rewrite forward to mod_proxy) processing on the server. The following work-around is compatible with our larger rewrite chain:

<location /request/view>
   ...
   # passthrough to reprocess url matching
   RewriteRule "/request/view$" "$0/proxy" [PT]
</Location>
#new location that just uses ProxyPass
<Location /request/view/proxy>
   ProxyPreserveHost on
   ProxyPass ajp://127.0.0.1:8009/other/view retry=0
   ProxyPassReverse ajp://127.0.0.1:8009/request/view
</Location>

I suspect that the way mod_rewrite hands off to mod_proxy on our server, is very inefficient when using ssl.

sgc
  • 41
  • 5