0

I am pretty much a newb at http configuration, so please bear with me (I inherited support of this system).

My web server is running behind an F5 which handles all of the https handshaking. If the incoming request is for http, the F5 passes the request to the web server on port 80. If the incoming request is for https, the F5 handles all of the handshaking and then passes the request to the web server on port 81.

My httpd.conf file is set up to listen on ports 80 and 81. There is one Virtual Host defined for port 81:

<VirtualHost 172.10.112.10:81>
  ServerName example.com
  DocumentRoot /usr/local/mwi/www/winxp/81
  RewriteEngine on
  RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$
  RewriteRule .* - [F]
</VirtualHost>

The directives "RewriteEngine on", "DocumentRoot /usr/local/mwi/www/winxs/80", and all RewriteCond and RewriteRule are outside of a Virtual Host block (and are not in any other block) which I take to mean that they are global directives.

My problem is that the rewrite rules process correctly when http://example.com/whatever is used but no rewriting is being done if the request is https://example.com/whatever. The website is returning a 404 (page not found). I found something yesterday (on the apache site) that said that the global directives are ignored if there is a Virtual host block that matches the incoming request.

I searched and found that I may be able to accomplish this using an htaccess file but is not recommended due to the performance hit (I do have access to the main httpd.conf file).

Do I need to create an additional Virtual Host block for port 80 and move all of the Rewrite directives into it?

Do I also need to copy all of the Rewrite directives to the Virtual Host for port 81?

I would prefer to maintain only one set of Rewrite directives for both ports. How can I best accomplish this?

Thanks in advance.

Harley

0

If you don't want to double your rewrite configuration, then you could include it from an external file:

Include files in Apache HTTP Server Version 2.2 httpd.conf

Two separate blocks each including one rewrite would probably be neatest indeed.

0

JayMcTee - thank you. I used your answer and figured out my issue. I had to create a Virtual Host for the port 80 requests and remove the global rewrite directives.

From the way I understood the apache doc, I thought that the global rewrite directives would always be used no matter what port the request came in on. A deeper reading of the doc had a statement saying that if a request was handled by a Virtual Host, then only the rewrite directives specified in that Virtual Host would be used. Initially, I tried to simply copy the rewrite directives in the port 81 Virtual Host but still had the issue. I then created a Virtual Host for port 80 and used the Include directive in both Virtual hosts.

Problem solved!

Your Answer

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.