Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use https?

Tags:

https

ssl

If on the server, we already setup/configured the SSL certificate, how could I make my websites using secure page? Just make the linke to https://example.com/etc.php?

Thanks!

like image 821
Zhao Peng Avatar asked Apr 06 '12 03:04

Zhao Peng


1 Answers

Two things have to be in place.

  1. You'll need to setup the ssl cert properly, which it sounds like you have
  2. As the other commentator said, this will depend upon which webserver you're using. More likely than not, apache:

Apache:

You'll need to modify the apache settings to support the https version of your site. If you're using a modern installation of Apache2 with virtual hosts, usually there will be a "sites-available" directory where individual config files exists for each domain. For a domain that will have both http and https (80 and 443), you would do something like this, assuming apache is listening on 127.0.0.1 (this would not be the case for most apache installations, so be sure to change the ip). It also goes without saying that you need to change the paths and domain name in the following:

<VirtualHost 127.0.0.1:80>
  ServerAdmin [email protected]
  ServerName somebody.com
  ServerAlias www.somebody.com
  DocumentRoot /home/somebody/www
  <Directory "/home/somebody/www">
        Options FollowSymLinks
        AllowOverride All
        Options -Indexes
  </Directory>
  ErrorLog /home/logs/somebody.error.log
  CustomLog /home/logs/somebody.access.log combined
</VirtualHost>
<VirtualHost 127.0.0.1:443> SSLEngine On SSLCertificateFile /etc/apache2/ssl/something.crt SSLCertificateKeyFile /etc/apache2/ssl/something.key SSLCertificateChainFile /etc/apache2/ssl/gd_bundle.crt ServerAdmin [email protected] ServerName somebody.com ServerAlias www.somebody.com DocumentRoot /home/somebody/www <Directory "/home/somebody/www"> Options FollowSymLinks AllowOverride All Options -Indexes </Directory> ErrorLog /home/logs/somebody.ssl.error.log CustomLog /home/logs/somebody.ssl.access.log combined </VirtualHost>

If you are using nginx, there is a similar dual block you'll need to have for :80 and :443. Look at the block you already have for 80 and consult their documentation:

http://nginx.org/en/docs/http/configuring_https_servers.html

You may also be using iis, in which case, here are the instructions for version 7:

How do I configure a site in IIS 7 for SSL?

like image 181
Jonathan Barlow Avatar answered Oct 13 '22 22:10

Jonathan Barlow