Apache with SSL and http redirection to https on Ubuntu
The TLS (transport layer security) and its predecessor
SSL( secure sockets layer) are the secure
protocols created in order to place normal traffic in a protected, encrypted
wrapper.
These protocols allow traffic to be sent safely between
remote parties with secure data transfer
where data is being intercepted
and read by someone else in the middle.
In this guide, will learn how to create a self-signed SSL
certificate for Apache on an Ubuntu 14.04 server. Which will allow you to encrypt traffic from your
server to client . While this does not provide the benefit of third party
validation of your server's identity, it only full fills the requirements of
those simply wanting to transfer information securely to the client.
Update the linux using this command
# sudo apt-get update
Install the apache if not installed
# sudo apt-get install apache2
Activate the SSL Module
Enable the module by typing
# sudo a2enmod ssl
After you have enabled SSL, you'll have to restart the
web server for the change to be recognized:
#sudo service apache2 restart
Create a Self-Signed SSL
Certificate
# sudo mkdir /etc/apache2/ssl
# sudo openssl req -x509 -nodes
-days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/test.key -out
/etc/apache2/ssl/test.crt
Generating a 2048 bit RSA
private key
................+++
.............+++
/etc /apache2/ssl/test. key: No
such file or directory
140611063744160: error: 02001002: system
library: fopen : No such file or directory: bs
s_file. c: 398: fopen( '/etc/apache2/ssl/test. key','w')
140611063744160: error: 20074002: BIO
routines: FILE_CTRL: system lib: bss_file. c: 400:
root@osticket: ~# mkdir
/etc/apache2/ssl
root@osticket:~# sudo openssl
req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/test.key
-out /etc/apache2/ssl/test.crt
Generating a 2048 bit RSA
private key
.+++
..................+++
-----
You are about to be asked to
enter information that will be incorporated
What you are about to enter is
what is called a Distinguished Name or a DN.
There are quite a few fields
but you can leave some blank
For some fields there will be a
default value,
If you enter '.', the field
will be left blank.
-----
Country Name (2 letter code)
[AU]: IN
State or Province Name (full
name) [Some-State]: Telengana
Locality Name (eg, city)
[]: Hyderabad
Organization Name (eg, company)
[Internet Widgits Pty Ltd]: test
Organizational Unit Name (eg,
section) []: helpdesk
Common Name (e.g. server FQDN
or YOUR name) []:helpdesk.test.com
Email Address []:test@xyz.com
Configure Apache to Use SSL
# vi
/etc/apache2/sites-enabled/default-ssl.conf
<VirtualHost
192.168.0.1:443>
DocumentRoot /var/www/
SSLCertificateFile /etc/apache2/ssl/apache. crt
SSLCertificateKeyFile /etc/apache2/ssl/apache. key
</VirtualHost >
Activate the SSL Virtual
Host
# sudo a2ensite
default-ssl. conf
# service apache2 restart
This should enable your new virtual host, which will
serve encrypted content using the SSL certificate you created.
To Redirect http to https 80
- 443
Comment to <virtual
host *: 80> section and add
# vi /etc/apache2/apache2. conf
<VirtualHost *: 80>
Redirect /scp
https://192.168.87.138/scp
DocumentRoot /var/www/html/osticket/upload
</VirtualHost >
#<VirtualHost *: 80>
# ServerName 192.168.87.138
# DocumentRoot /var/www/html/osticket/upload
#</VirtualHost>
Comments
Post a Comment