Add SPDY support to Apache web server with mod_spdy
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
- Apche ต้องรันแบบ Worker MPM ตัวอย่างเช่น รันด้วย mod_fcgid
- Install Apache webserver, mod_ssl และ openssl:
123[root@ezylinux ~]# yum install httpd mod_ssl openssl - เนื่องจาก SPDY protocol ใช้ https ในการทำงาน ดังนั้นเราจึงต้องสร้าง certificate ขึ้นมาเพื่อให้รองรับการทำงานแบบ https (ไม่สามารถทำงานแบบ http ได้)
- สร้าง private key:
123[root@ezylinux ~]# openssl genrsa -out ca.key 1024 - สร้าง CSR:
123[root@ezylinux ~]# openssl req -new -key ca.key -out ca.csr - สร้าง Self Signed Key:
123[root@ezylinux ~]# openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt - Copy ไฟล์ทั้งหมดไปไว้ที่ /etc/http/ssl
12345[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
1234567891011121314151617ServerAdmin admin@ezylinux.comDocumentRoot /var/www/ezylinux.comServerName www.ezylinux.comErrorLog logs/ezylinux.com-errorlogCustomLog logs/ezylinux.com-accesslog combinedSSLEngine onSSLProtocol all -SSLv2SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOWSSLCertificateFile /etc/http/ssl/ca.crtSSLCertificateKeyFile /etc/http/ssl/ca.key</pre></li></ul></ul><ul>
- สร้าง private key:
- Download SPDY (mod_spdy) ด้วยคำสั่ง
- SPDY (mod_spdy) สำหรับ 32bit:
123[root@ezylinux ~]# wget https://dl-ssl.google.com/dl/linux/direct/mod-spdy-beta_current_i386.rpm - SPDY (mod_spdy) สำหรับ 64bit:
123[root@ezylinux ~]# wget https://dl-ssl.google.com/dl/linux/direct/mod-spdy-beta_current_x86_64.rpm
- SPDY (mod_spdy) สำหรับ 32bit:
- Install mod-spdy for Apache
123[root@ezylinux ~]# yum install --nogpgcheck mod-spdy-beta_current_x86_64.rpm - ทำการตรวจสอบความถูกต้องของ config ด้วยคำสั่ง
123[root@ezylinux ~]# /etc/init.d/httpd configtest - Restart apache service ด้วยคำสั่ง
123[root@ezylinux ~]# /etc/init.d/httpd restart
การทดสอบ SPDY ว่า apache server ได้เปิดให้ใช้งาน SPDY หรือยัง ให้เปิด Chrome และเข้าไปที่
[text]chrome://net-internals/#spdy[/text]
Video ทดสอบ speed ของ https กับ SPDY (mod_spdy)