I have some common configuration for both port 443 and port 80. But I want for port 443 some specific configuration (like turning SSLEngine On). How can I get this working?

link|improve this question

17% accept rate
belongs on serverfault. – Daniel A. White Jul 13 '11 at 12:43
3  
How about having two separate virtual hosts for the two ports, but include a common config file in both? – Kerrek SB Jul 13 '11 at 12:45
feedback

migrated from stackoverflow.com Jul 13 '11 at 12:53

This question came from our site for professional and enthusiast programmers.

1 Answer

As Kerrek already mentioned, you can easily setup two VirtualHost directives for each, then put an Include directive in each pointing to a file with the common elements.

If the server is only hosting a single site, you can put the common elements in the global configuration and setup a virtual host for the https site with the additional directives for it.

link|improve this answer
The hard part is when you want any login/password entry to redirect to the ssl version of the site. – Koos van den Hout Jul 16 '11 at 19:15
@Koos, sounds like something that can easily be put into the login webpages (if forms based) or a quick mod_rewrite directive. – Chris S Jul 16 '11 at 22:31
I later found the ideal trick myself: A 402 handler (authentication required) which redirects to the ssl version. – Koos van den Hout Oct 16 '11 at 15:36
@KoosvandenHout A 402 is a redirect, not the mechanism on the server which triggers it. You would need application logic of some kind issuing the 402, such as mod_rewrite or something in PHP/Perl/whatever. – Chris S Nov 23 '11 at 14:29
402 state is authentication required. You define a handler for this state (can be done in apache) which gives a different answer: the 302 (temporary redirect) to the SSL version. Can be done as a perl/php script. – Koos van den Hout Nov 26 '11 at 17:53
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

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