เว็บเซิร์ฟเวอร์และโฮสติ้ง

Add SPDY support to Apache web server with mod_spdy

google-spdy-protocol SPDY (speedy) เป็น networking protocol สำหรับเวปที่ถูกพัฒนาโดย Google เพื่อช่วยลดเวลาการโหลดหน้าเวปและเพิ่มความปลอดภัยให้กับเวป SPDY กำลังถูกพลักดันให้เป็น standard protocol และในปัจจุบันก็เป็น Internet Draft เป็นที่เรียบร้อยแล้ว สำหรับ browser ที่รองรับการทำงานในตอนนี้ก็มี Google Chrome และ Mozilla Firefox ข้อดีของ SPDY (speedy):

  • web server และ browser สามารถ compress HTTP headers เพื่อช่วยลดการส่งข้อมูล
  • ถ้าหากเรียกใช้งานทรัพยากรหลายตัวสามารถรวมการเรียกใช้ให้เป็น 1 TCP connection เพื่อช่วยลด connections บน network
  • Browser สามารถขอแหล่งข้อมูลหน้าทั้งหมดในครั้งเดียว ซึ่งจะช่วยลดจำนวนรอบการรับส่งข้อมูลระหว่าง web server และ browser

การ config ให้ Apache web server รองรับการทำงาน SPDY protocol

  1. Apche ต้องรันแบบ Worker MPM ตัวอย่างเช่น รันด้วย mod_fcgid

  2. Install Apache webserver, mod_ssl และ openssl:

    [root@ezylinux ~]# yum install httpd mod_ssl openssl
  3. เนื่องจาก SPDY protocol ใช้ https ในการทำงาน ดังนั้นเราจึงต้องสร้าง certificate ขึ้นมาเพื่อให้รองรับการทำงานแบบ https (ไม่สามารถทำงานแบบ http ได้)

    • สร้าง private key:

      [root@ezylinux ~]# openssl genrsa -out ca.key 1024
    • สร้าง CSR:

      [root@ezylinux ~]# openssl req -new -key ca.key -out ca.csr
    • สร้าง Self Signed Key:

      [root@ezylinux ~]# openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
    • Copy ไฟล์ทั้งหมดไปไว้ที่ /etc/http/ssl

      [root@ezylinux ~]# cp ca.crt /etc/http/ssl
      [root@ezylinux ~]# cp ca.key /etc/http/ssl/ca.key
      [root@ezylinux ~]# cp ca.csr /etc/http/ssl/ca.csr
    • สร้าง virtual host ให้รองรับการทำงานแบบ https

      
      ServerAdmin [email protected]
      DocumentRoot /var/www/ezylinux.com
      ServerName www.ezylinux.com
      ErrorLog logs/ezylinux.com-errorlog
      CustomLog logs/ezylinux.com-accesslog combined
      
      SSLEngine on
      SSLProtocol all -SSLv2
      SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
      SSLCertificateFile /etc/http/ssl/ca.crt
      SSLCertificateKeyFile /etc/http/ssl/ca.key</pre>
      </li>
      </ul>
      </ul>
      <ul>
  4. Download SPDY (mod_spdy) ด้วยคำสั่ง

    • SPDY (mod_spdy) สำหรับ 32bit:

      [root@ezylinux ~]# wget https://dl-ssl.google.com/dl/linux/direct/mod-spdy-beta_current_i386.rpm
    • SPDY (mod_spdy) สำหรับ 64bit:

      [root@ezylinux ~]# wget https://dl-ssl.google.com/dl/linux/direct/mod-spdy-beta_current_x86_64.rpm
  5. Install mod-spdy for Apache

    [root@ezylinux ~]# yum install --nogpgcheck mod-spdy-beta_current_x86_64.rpm
  6. ทำการตรวจสอบความถูกต้องของ config ด้วยคำสั่ง

    [root@ezylinux ~]# /etc/init.d/httpd configtest
  7. Restart apache service ด้วยคำสั่ง

    [root@ezylinux ~]# /etc/init.d/httpd restart

การทดสอบ SPDY ว่า apache server ได้เปิดให้ใช้งาน SPDY หรือยัง ให้เปิด Chrome และเข้าไปที่

chrome://net-internals/#spdy

Video ทดสอบ speed ของ https กับ SPDY (mod_spdy)

EOF.← กลับไปอ่านบทความอื่น