2

I am using RewriteRule in my .htaccess file to modify an incoming URL. It works fine except I want the rule to act as a proxy, rather than a redirect. But if I append the [P] proxy flag to the rule then the rule triggers a 500 error. The Apache logs show a 500 log when the rewrite rule includes the "P" flag and a normal 302 log for the same URL when the rule does not include the "P" flag. Note that the result is the same for any valid URL pattern and URL substitution specified in the rewrite rule.

I enabled mod_proxy and mod_proxy_http by entering sudo a2enmod proxy and sudo a2enmod proxy_http followed by sudo systemctl restart apache2 but I'm still getting the 500 error. When I enter apachectl -M the following two lines appear in the list:

proxy_module (shared)
proxy_http_module (shared)

Does anyone know what else is needed to get RewriteRule's proxy flag to work?

New contributor
Bob Arlof is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    What is the relevant configuration? What is in the error log? – Michael Hampton May 12 at 22:41
  • @MichaelHampton - The Apache logs show a 500 log when the rewrite rule includes the "P" flag and a normal 302 log for the same URL when the rule does not include the "P" flag. I'm not sure what configuration you're referring to, but I did not include the syntax of rewrite rule since the result is the same for any valid rule URL pattern and rule URL substitute. – Bob Arlof May 12 at 23:45
  • 2
    First, you should show an actual RewriteRule. Second, you should check the error log. – Michael Hampton May 12 at 23:57
  • 1
    The 500 server response (that appears in the server's "access log") is just a generic "catch all" HTTP response for when the server is unable to handle the request (there was an "Internal Server Error" of some kind). The server's "error log" should contain the specific details of this "server error". – MrWhite May 13 at 0:07
  • 1
    Thanks @MichaelHampton and MrWhite, the error logs did indeed provide the answer (SSLProxyEngine needed to be enabled). It is the first time I've had to look at the Apache logs in a few years and had forgotten the errors are in separate files. My bad. – Bob Arlof May 13 at 0:34
1

SSLProxyEngine needs to be set to "on" in the site's Apache conf file.

New contributor
Bob Arlof is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Bob Arlof is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.