Changes between Initial Version and Version 1 of netsec2018apache


Ignore:
Timestamp:
Jun 7, 2018, 9:44:24 AM (6 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • netsec2018apache

    v1 v1  
     1= HTTPS with Self-Signed Certificates =
     2
     3In this Lab we will install a web server (Apache2) and enable https with the use of self-signed ssl certificates. Lab session has to be done in the ubuntu VM
     4
     5== Install Apache2 ==
     6
     7Apache is a web server application that is widely used in the internet for more than 20 years and it is a well-documented piece of Free and Open Source Software managed by Apache Foundation.
     8(https://httpd.apache.org/)
     9
     10Before installing we need to update our repositories. Therefore we will first add debian apache repo to our list and do a update on the list. Since we will be using sudo commands, It will ask you for your user's password as these processors will be granted root privileges.
     11{{{
     12sudo add-apt-repository ppa:ondrej/apache2
     13}}}
     14
     15When Asked press ‘Enter’ to Continue. Once the ppa is imported do an update.
     16{{{
     17sudo apt-get update
     18}}}
     19
     20Once the repo lists are updated run,
     21{{{
     22sudo apt-get install apache2
     23}}}
     24
     25When asked press '''Y''' and hit '''Enter''' to continue, and the installation will proceed.
     26
     27Check installed apache version details by issuing,
     28{{{
     29$ apache2 -v
     30}}}
     31
     32Now go to your host machine. Open a web browser and type IP address of your Ubuntu VM. You will get the Apache default page.
     33
     34== Self-Signed Certificate ==
     35
     36Use the following Command to create the certificate and the key
     37{{{
     38sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache_prv.key -out /etc/ssl/certs/apache_crt.crt
     39}}}
     40You will be asked series of questions, answer them carefully
     41{{{
     42Country Name (2 letter code) [AU]:LK
     43State or Province Name (full name) [Some-State]:Kandy
     44Locality Name (eg, city) []:Peradeniya
     45Organization Name (eg, company) [Internet Widgits Pty Ltd]:YourInst
     46Organizational Unit Name (eg, section) []:IT Team
     47Common Name (e.g. server FQDN orYOUR name) []:
     48Email Address []:info@yourname.ac.lk
     49}}}
     50Once finished, it will create two files in /etc/ssl. Private will be saved as apache_prv.key and certificate will be saved as apache_crt.crt
     51
     52== Configure apache ==
     53
     54lets create virtual host files for the web
     55{{{
     56sudo nano /etc/apache2/sites-available/lab.conf
     57}}}
     58
     59Include the following
     60{{{
     61<IfModule mod_ssl.c>
     62    <VirtualHost _default_:443>
     63         ServerAdmin admin@yourname.ac.lk
     64         DocumentRoot /var/www/html
     65         <Directory /var/www/html>
     66                  Require all granted
     67         </Directory>
     68         ErrorLog ${APACHE_LOG_DIR}/error.log
     69         CustomLog ${APACHE_LOG_DIR}/access.log combined
     70         SSLEngine on
     71         SSLCertificateFile      /etc/ssl/certs/apache_crt.crt
     72         SSLCertificateKeyFile /etc/ssl/private/apache_prv.key
     73         <FilesMatch "\.(cgi|shtml|phtml|php)$">
     74                  SSLOptions +StdEnvVars
     75         </FilesMatch>
     76         <Directory /usr/lib/cgi-bin>
     77                  SSLOptions +StdEnvVars
     78         </Directory>
     79         </VirtualHost>
     80</IfModule>
     81}}}
     82
     83Now enable this site and ssl by
     84{{{
     85sudo a2enmod ssl
     86sudo a2ensite web1-ssl.conf
     87}}}
     88
     89Try browsing from your host machine https://<IP address of the Ubuntu VM>, you will be warned about the untrusted connection as it is a self-signed authentication.