Author Topic: การทำ multiple ssl domain (https) on one ip ผ่าน nginx และ apache  (Read 4417 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
ปกติในส่วนของ เว็บเซิฟเวอร์ที่เป็น apache เวลาที่เราจะแอดเว็บที่ให้ใช้งาน certificate website ผ่าน (https:)
ต้องแอด global ip ให้กับเว็บนั้นๆด้วย ซึ่งถ้ามีเว็บจะใช้งาน https: (5) เว็บ ก็ต้องเตรียม ipv4 (5 ) ip เลย
ซึ่งปัจจุบัน ipv4 นั้นก็เหลือน้อยลงมากทีเดียว ซึ่งสามารถแก้ไขปัญหาโดยใช้งานเป็น nginx แทนได้ครับ
ซึ่ง nginx มี feature ที่สามารถ map https: หลายๆเว็บ ให้เรียกใช้งานผ่าน global ip ที่เป็น ipv4 ตัวเดียวได้เลย ไม่ยากครับ ลองดูๆ ^^

ลง os , nginx เสร็จ
#sudo apt-get install nginx

ก็ configure เลยครับ

#sudo nano /etc/nginx/sites-available/example.com
 server {

        listen   443;
        server_name example.com;

        root /usr/share/nginx/www;
        index index.html index.htm;

        ssl on;
        ssl_certificate /etc/nginx/ssl/example.com/server.crt;
        ssl_certificate_key /etc/nginx/ssl/example.com/server.key;
}

sudo nano /etc/nginx/sites-available/example.org

 server {

        listen   443;
        server_name example.org;

        root /usr/share/nginx/www;
        index index.html index.htm;

        ssl on;
        ssl_certificate /etc/nginx/ssl/example.org/server.crt;
        ssl_certificate_key /etc/nginx/ssl/example.org/server.key;
}

#sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
#sudo ln -s /etc/nginx/sites-available/example.org /etc/nginx/sites-enabled/example.org

#sudo service nginx restart

reference : https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-ssl-certificates-on-one-ip-with-nginx-on-ubuntu-12-04
« Last Edit: มีนาคม 25, 2018, 10:03:03 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: การทำ multiple ssl domain (https) on one ip ผ่าน apache
« Reply #1 on: มีนาคม 25, 2018, 10:02:50 PM »
cd /etc/httpd/conf.d
cp ssl.conf ssl_backup.conf

เริ่มทำการ configure เลยครับ
vi ssl.conf


NameVirtualHost *:443

<VirtualHost *:443>
 ServerName www.yoursite.com
 DocumentRoot /var/www/site
 SSLEngine on
 SSLCertificateFile /path/to/www_yoursite_com.crt
 SSLCertificateKeyFile /path/to/www_yoursite_com.key
 SSLCertificateChainFile /path/to/DigiCertCA.crt
</VirtualHost>

<VirtualHost *:443>
 ServerName www.yoursite2.com
 DocumentRoot /var/www/site2
 SSLEngine on
 SSLCertificateFile /path/to/www_yoursite2_com.crt
 SSLCertificateKeyFile /path/to/www_yoursite2_com.key
 SSLCertificateChainFile /path/to/DigiCertCA.crt
</VirtualHost>

เสร็จแล้วทำการเชค configure ว่ามีผิดหรือเปล่า
httpd -t
ถ้าขึ้น syntax OK
ก็ restart service 1 รอบครับ
/etc/init.d/httpd restart

แล้วทดสอบเข้าเว็บดูครับผม