Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an Apache web server running on Ubuntu 10.04, and I would like to switch everything to HTTPS.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Apache2 makes this very easy with the additional tools packaged with it. If you have the apache2-common package installed, you can enable the mod_ssl module (required for HTTPS) in one easy command:

sudo a2enmod ssl

Apache2 also includes a command to help you easily generate self-signed certificates called apache2-ssl-certificate. Generate your certificate for the server as shown below or use certificates purchased through a trusted root CA ( Verisign, Entrust, Thawte, etc ).

sudo apache2-ssl-certificate -days 365

Keep in mind, users will receive this infamous warning when viewing your site if you use a self-signed certificate:

enter image description here

Use the following 4 statements in your Apache configuration ( /etc/apache2/sites-available/default ) or VirtualHost directive ( below DocumentRoot ) to turn on the SSL Engine for that particular site:

SSLEngine on
SSLOptions +StrictRequire
SSLCertificateFile    /etc/apache2/ssl/certs/apache.crt
SSLCertificateKeyFile /etc/apache2/apache-ssl/apache.pem

The SSLOptions +StrictRequire forces SSL communication only for that particular site. The SSLCertificateFile and SSLCertificateKeyFile specify the locations to your SSL certificate and it's corresponding key.

Ensure we are listening on port 443 by modifying /etc/apache2/ports.conf to include the Listen directive:

echo "Listen 443" >> /etc/apache2/ports.conf

Finally you must restart Apache2 to initiate the changes:

sudo /etc/init.d/apache2 restart 

Additional Fun:

Configure HTTP requests on port 80 to redirect to port 443 with mod_rewrite.

Note:

Some of this data is from past experience with Debian/Ubuntu systems, for the most accurate instructions there is a guide for 10.04 on the Ubuntu website.

share|improve this answer

I'm not telling you how to do this, it's beyond the scope of this forum IMO(1). I'm only saying what I think you can do.

There really isn't an easy way to do this. You really have to know a bit about apache configuration and dig down in the configuration files. In addition to that you need a SSL certificate

The easiest way would be to tell your web server to stop listening to port 80(2) and only listen to port 443. A better solution would be to have apache redirect all connections to port 80 to port 443

(1) And beyond my expertise
(2) Or block port 80 in your firewall

share|improve this answer
    
I just noticed I stole the same link as you for mod_rewrite. Have a +1 :) –  John T Jul 15 '11 at 13:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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