หน้าเว็บ

วันศุกร์ที่ 3 มิถุนายน พ.ศ. 2559

เปิดใช้งาน HTTPS ใน Apache

1.Install the OpenSSL package in the Server
[code=bash]sudo apt-get install openssl[/code]
2.Enable the SSL and Rewrite module
[code=bash]sudo a2enmod ssl
sudo a2enmod rewrite[/code]
3.Create the directory for SSL Certificates
[code=bash]sudo mkdir -p /etc/apache2/ssl[/code]
4.Generate Self Signed Certificate (ตัวอย่างสำหรับ ownCloud)
[code=bash]sudo openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/owncloud.pem -keyout /etc/apache2/ssl/owncloud.key[/code]
5.Configure Apache
[code=bash]sudo nano /etc/apache2/apache2.conf [/code]
add
[code=conf]IncludeOptional conf.d/*.conf[/code]
ownCloud configuration for apache
[code=bash]sudo nano /etc/apache2/conf.d/owncloud.conf [/code]
[code=conf]<VirtualHost *:80>
ServerName example.com
ServerAlias http://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 http://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>[/code]
6.Restart apache
[code=bash]sudo /etc/init.d/apache2 restart[/code]
ที่มา : http://sharadchhetri.com/2014/03/09/setup-owncloud-6-self-signed-ssl-certificate-ubuntu-13-10/

ไม่มีความคิดเห็น:

แสดงความคิดเห็น