Httpd Redirect To Secure Content: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Internal=
=Internal=


* [[httpd Configuration#Subjects]
* [[httpd Configuration#Subjects]]


=Overview=
=Overview=
Line 11: Line 11:
Declare two virtual sites, one secure and one unsecure, under the same <tt>ServerName</tt>.  
Declare two virtual sites, one secure and one unsecure, under the same <tt>ServerName</tt>.  


Details on how to configure virtual hosts are available here: [[]]
Details on how to configure virtual hosts are available here: [[httpd Virtual Host Configuration]]


Details on how to secure a site with SSL are available here: [[]]
Details on how to secure a site with SSL are available here: [[httpd SSL Configuration]]
 
<pre>
    ...
 
    <VirtualHost *:80>
        ServerName praetorian.novaordis.com
        Redirect / https://praetorian.novaordis.com/
    </VirtualHost >
 
    <VirtualHost *:443>
        ServerName praetorian.novaordis.com
        # SSL configuration
    </VirtualHost >
 
  ...
</pre>
 
'''Note'''
:Make sure the httpd process listens on both ports (80 and 443).
 
More details about Redirect are available here [[httpd Redirect|Redirect]].

Latest revision as of 03:21, 7 January 2016

Internal

Overview

It is sometimes desirable to serve the content of a web site over HTTPS but not over HTTP. However, it is nice to provide a redirect service for the entire HTTP site, so the users are automatically redirected to the secure site when they try to access the unsecured content. One way of implementing this is presented below.

Procedure

Declare two virtual sites, one secure and one unsecure, under the same ServerName.

Details on how to configure virtual hosts are available here: httpd Virtual Host Configuration

Details on how to secure a site with SSL are available here: httpd SSL Configuration

    ...

    <VirtualHost *:80>
        ServerName praetorian.novaordis.com
        Redirect / https://praetorian.novaordis.com/
    </VirtualHost >

    <VirtualHost *:443>
        ServerName praetorian.novaordis.com
        # SSL configuration
    </VirtualHost >

   ...

Note

Make sure the httpd process listens on both ports (80 and 443).

More details about Redirect are available here Redirect.