Apache2 - Secure Sockets Layer
การสร้าง self-siged SSL certificate
Secure Sockets Layer (SSL) คือ โปรโตคอลความปลอดภัย ที่ถูกใช้เป็นมาตรฐาน ในการเพิ่มความปลอดภัย ในการสื่อสารหรือส่งข้อมูลบนเครือข่ายอินเทอร์เน็ต
ก่อนอื่น คุณต้องแน่ใจว่า คุณได้ติดตั้ง Apache2, openssl แล้ว
1. สร้าง Certificate Authority (CA).
CA:
Common Name (CN) : Issued Name
Organization (O): Organization Name
Organizational Unit (OU): Development Name
# openssl genrsa -des3 -out ca.key 4096
# openssl req -new -x509 -days 365 -key ca.key -out ca.crt
(-days 365 คุณสามารถเปลื่ยนเป็นกี่ปีก็ได้ เช่น 10 ปี ก็ใส่เป็น 3650 เป็นต้นครับ)
Server:
Common Name (CN) : Website Name
Organization (O): Organization Name
Organizational Unit (OU): Development Name
2. สร้าง Key Server (csr)
# openssl genrsa -des3 -out server.key 4096
# openssl req -new -key server.key -out server.csr
3. ทำ self-created certificate authority (CA) และ Sign certificate signing request (csr)
# openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01001 -out server.crt
(-set_serial 01001 คุณสามารถเปลื่ยนหมายเลข Serial ได้ครับ )
# openssl rsa -noout -text -in server.key
# openssl req -noout -text -in server.csr
# openssl rsa -noout -text -in ca.key
# openssl x509 -noout -text -in ca.crt
4. ทำ server.key password apache
# openssl rsa -in server.key -out server.key.insecure
# mv server.key server.key.secure
# mv server.key.insecure server.key
5. Copy ไฟล์ ไปยัง /etc/apache2/
# cp server.key /etc/apache2/ssl.key
# cp server.crt /etc/apache2/ssl.crt
# cp server.csr /etc/apache2/ssl.csr
6. สร้าง SSL Directory (ถ้าต้องการทำเป็น Virtual Hosting SSL) ถ้าไม่ต้องการ ข้ามเลยครับ
# cd /srv
# mkdir www-ssl
# cd www-ssl
# mkdir htdocs
# cd htdocs
# echo "ssl index page by susethailand.com" >index.html
7. Direct Apache2 to load SSL module
# vi /etc/sysconfig/apache2
APACHE_SERVER_FLAGS="SSL"
8. Setup Virtual Host SSL port.
# cd /etc/apache2/vhost.d/
# cp vhost-ssl.template vhost-ssl.conf
# vi vhost-ssl.conf
<VirtualHost_default_:443>
DocumentRoot"/srv/www/htdocs"
#DocumentRoot"/srv/www-ssl/htdocs" (ถ้าต้องการทำเป็น Virtual Hosting SSL) ถ้าคุณทำข้อ 6 มาให้ uncomment
ServerName www.yoursite.com:443
ServerAdmin admin@yoursite.com
ล่างสุดใต้ </VirtualHost> เพิ่ม
<Directory "/srv/www/htdocs">
#DocumentRoot"/srv/www-ssl/htdocs" (ถ้าต้องการทำเป็น Virtual Hosting SSL) ถ้าคุณทำข้อ 6 มาให้ uncomment
AllowOverride None
Order allow,deny
Allow from all
</Directory>
9. Firewall
YaST -> Security & Users -> Firewall -> Allowed Services
ทำการ Add HTTP และ HTTPS ใน External Zone.
11. Restart apache2
# rcapache2 restart
*** ถ้าไม่มี Error ก็แสดงว่าเป็นอันเสร็จครับ ถ้ามี Error ก็ post ลงใน Forum นะครับ.
*** ทดสอบ พิมพ์ https://yoursite.com <Enter>
เป็นอันเสร็จครับ.

SUSE Linux Enterprise Cool Solutions
|







