Record the process of adding SSL (https) to the website server once

Source: Internet
Author: User

Record the process of adding SSL (https) to the website server once

It is said that HTTPS is better and safer now, and HTTPS is also added to your website to record this process.

Try accessing http://andaily.com.

-Hardware environment

Operating System: Ubuntu 12.04.1 LTS

Server: Apache Server 2.2.22

SSL Certificate: waotong free SSL Certificate G2 (Application address: https://buy.wosign.com/applyforssl.htmlselect the first free SSL Certificate)

-Main Steps

1. After applying for free SSL, the SSL Certificate will be downloaded. There are three Apache certificate files: 1_root_bundle.crt; 2_xxx.crt; 3_xxx.key. (xxx is the domain name at the time of application, the same below)

Copy the three files to any location on the server (it is recommended to put them in the/etc/apache2/ssl/directory)

 

2. Enable the SSL module and use the command

 

a2enmod ssl

 


3. In the/etc/apache2 directory, copy sites-available/default-ssl to the sites-enabled directory and change its name to 001-ssl.

Edit the-SSL file and add the following content under SSLEngine on.

 

        SSLCertificateFile    /etc/apache2/ssl/2_xxx.crt        SSLCertificateKeyFile /etc/apache2/ssl/3_xxx.key
        SSLCACertificateFile  /etc/apache2/ssl/1_root_bundle.crt

 

 

Save and exit.

 

4. Reload Apache configuration and restart Apache

 

/etc/init.d/apache2 force-reload
/etc/init.d/apache2 restart


 

OK. Now your website supports https access (http access is also available)

If the website needs to Use https forcibly (http is no longer supported, it will be forcibly redirected to https during http access), the configuration is as follows:

In the/etc/apache2 directory, edit the sites-available/default file. Add the following content

 

        # Force HTTPS        RewriteEngine on        RewriteCond   %{HTTPS} !=on        RewriteRule   ^(.*)  https://%{SERVER_NAME}$1 [L,R]

This configuration redirects all http requests to https.

OK. I hope it will help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.