5

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?

Bob Arlof
  • 171
  • 4
  • 1
    What is the relevant configuration? What is in the error log? – Michael Hampton May 12 '19 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 '19 at 23:45
  • 2
    First, you should show an actual RewriteRule. Second, you should check the error log. – Michael Hampton May 12 '19 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 '19 at 00: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 '19 at 00:34

2 Answers2

2

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

Bob Arlof
  • 171
  • 4
-2

I have get same issue. Fixed by add the following code to Apache conf file:

SSLProxyEngine on
  • This has already been posted, there is no need to add the same answer again. After earning some reputation you can upvote helpful answers. – Gerald Schneider Mar 30 '22 at 08:38