Setup Owncloud 6 with self signed SSL certificate on Ubuntu 13.10
Setup Owncloud 6 with self signed SSL certificate on Ubuntu 13.10
In this tutorial, we will setup Owncloud 6 with self signed SSL certificate on Ubuntu 13.10 Server.In other words,setting HTTPS for Owncloud 6 in Ubuntu 13.10 Server.In recent months, Owncloud 6 has been released.In our last post,we have already written document on “how to install Owncloud 6 in Ubuntu 13.10 Server“.Hence, we expect,you have already setup the Owncloud 6.x on Ubuntu 13.10 Server.
IMPORTANT NOTE : There is a one major difference in Ubuntu 13.10 Server is,it is shipped with by-default Apache version 2.4. Hence,we have to configure the Apache as per version 2.4 .
Follow the given below steps, to setup Owncloud 6 with self signed SSL certificate/HTTPS on Ubuntu 13.10 Server
Step 1 : Install the OpenSSL package in the Server.This package is important to install,it helps to generate the SSL certificate.
1
|
sudo apt-get install openssl
|
Step 2 : Enable the SSL and Rewrite module in Apache 2.4 .
1
2
|
sudo a2enmod ssl
sudo a2enmod rewrite
|
Step 3: Now create the directory for SSL Certificates which will be generated with the help of command
openssl
.
1
|
sudo mkdir -p /etc/apache2/ssl
|
Step 4 : Generate Self Signed Certificate by using below given command.
1
|
sudo openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/owncloud.pem -keyout /etc/apache2/ssl/owncloud.key
|
Step 5: Configure Apache 2.4 Webserver in Ubuntu 13.10 Server(By-default in Ubuntu 13.10 Server edition, apache version 2.4 is shipped)
Note: There are some changes have been found in Apache 2.4 version related to configuration.
In previous post of setup Owncloud 6 in Ubuntu 13.10 Server,we are using /etc/apache2/conf.d/owncloud.conf file. Hence, we will edit the /etc/apache2/conf.d/owncloud.conf .
In case,you have owncloud configuration file in other path then edit that particular file.
In case,you have owncloud configuration file in other path then edit that particular file.
Description of our Server
Operating System : Ubuntu 13.10 Server edition
Arch : x86_64
Apache version : 2.4
Owncloud Version : 6.0 (or 6.x)
Arch : x86_64
Apache version : 2.4
Owncloud Version : 6.0 (or 6.x)
Owncloud DocumetRoot path : /var/www/owncloud
Owncloud configuration File Path : /etc/apache2/conf.d/owncloud.conf
Owncloud configuration File Path : /etc/apache2/conf.d/owncloud.conf
NOTE: We have written both IP based and Name based Virtual Host Apache configuration. Use anyone method as per your requirement
IP Based VirtualHost Apache configuration for https in Owncloud Server
(A) Edit apache2.conf file : Edit /etc/apache2/apache2.conf file.
And add the line IncludeOptional conf.d/*.conf at the end of file
And add the line IncludeOptional conf.d/*.conf at the end of file
1
|
sudo vi /etc/apache2/apache2.conf
|
1
2
3
|
### paste below given lines,at the end of file apache2.conf ###3
IncludeOptional conf.d/*.conf
|
Save and close the apache2.conf file . Restart the apache2 service
1
|
sudo /etc/init.d/apache2 restart
|
(B) Edit Owncloud configuration file:
Edit the /etc/apache2/conf.d/owncloud.conf file.
Edit the /etc/apache2/conf.d/owncloud.conf file.
1
|
sudo vi /etc/apache2/conf.d/owncloud.conf
|
Paste the below given contents.In this configuration we have configured SSL for owncloud and redirected all port 80 traffic to port 443 i.e HTTPS.
IMPORTANT NOTE : REPLACE 192.168.56.102 with your Server IP Address (use
ifconfig
command to find the ip address of server)
Optional Note: In case if you want both http and https running then remove all lines in between of line “#### Redirect to port 443 ###” and “#### End of Redirection configuration ###”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<VirtualHost 192.168.56.102:80>
#### Redirect to port 443 ###
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
#### End of Redirection configuration ###
DocumentRoot /var/www/owncloud/
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost 192.168.56.102:443>
####Configuration for SSL #####
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/owncloud.pem
SSLCertificateKeyFile /etc/apache2/ssl/owncloud.key
#### End of SSL Configuration ####
DocumentRoot /var/www/owncloud/
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
|
Save and close the file. Restart the apache2 service
1
|
sudo /etc/init.d/apache2 restart
|
Step C : Now Open the web browser and type ip address in URL address field.
For Example
http://192.168.56.102
(Replace 192.168.56.102 with your server ip address)NAME Based VirtualHost Apache configuration for https in Owncloud Server
To setup the name based virtual apache configuration,follow given below steps
(A) Edit apache2.conf file
Edit /etc/apache2/apache2.conf file.One parameter you have to modify and one parameter you have to add.
1
|
sudo vi /etc/apache2/apache2.conf
|
(i) Modify the value of “HostnameLookups Off” to “HostnameLookups On”
(ii) Add below given new line in apache2.conf file at the end of last line
IncludeOptional conf.d/*.conf
(B) Edit Owncloud configuration file.
Edit the Owncloud configuration file.In our system it is located in /etc/apache2/conf.d/owncloud.conf
1
|
sudo vi /etc/apache2/conf.d/owncloud.conf
|
Paste below given contents in /etc/apache2/conf.d/owncloud.conf file. Save and close the file after pasting
NOTE: Replace example.com with your Domain name
NOTE: Replace example.com with your Domain name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/owncloud.pem
SSLCertificateKeyFile /etc/apache2/ssl/owncloud.key
DocumentRoot /var/www/owncloud/
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
|
(C) Restart the apache2 service
1
|
sudo /etc/init.d/apache2 restart
|
(D) Open the web browser and type the domain name.
For example.
1
|
http://example.com
|
Replace example.com with your domain name in URL address field in web browser.
Comentarios
Publicar un comentario
Dime si la información de este blog te sirvio.