Sun 6 Apr 2008
โปรแกรม motion ที่ผมใช้งานอยู่นั้นเมื่อจะเอาภาพออกมาแสดงจะเป็นการ stremming ผ่านทาง TCP port เช่น 8001, 8002, 8003 เป็นต้น ซึ่งในการใช้งานก็เป็นอุปสรรคพอสมควร ถ้าหากปลายทางที่จะเรียกเข้ามาใช้งาน และที่ปลายทางแห่งนั้นมีการติดตั้งไฟร์วอลล์ ก็อาจจะไม่สามารถใช้งานได้ เพราะจากถูกปิดพอร์ท แรกๆนั้นผมใช้วีธีเขียนกำกับไว้ว่า “ถ้าหากไม่เห็นภาพเคลื่อนไหว อาจจเป็นไปได้ว่าคุณนั้นอยู่ภายใต้ไฟร์วอลล์” แน่นอนมันไม่ได้ช่วยให้เห็นภาพวีดีโอจากโปรแกรม motion เลย - -” ก็ได้ปล่อยปะละเลยมาเป็นปีๆ ไม่เคยจะแก้ไขปรับปรุงอะไร จนวันนี้มีงานชิ้นนึงทำให้ผมได้ใช้งานโมดูลของ apache ตัวหนึ่งชื่อว่า “mod_proxy” เลยคิดเอามาประยุคใช้กับโปรแกรม motion ของผมด้วยเลย
มาเริ่มต้นกันจากapache ที่ผมใช้งานเป็น apache2 (V.2.24) เริ่มโดยการโหลดโมดูล mod_proxy โดยการคัดลอกไฟล์ proxy.conf, proxy.load และ proxy_http.load จากพาร์ท mods-available มาไว้ที่พาร์ท mods-enabled จากนั้นทำการแก้ไขไฟล์ proxy.conf โดยตัวอย่างการใช้งานของผม โปรแกรม motion ทำงานอยู่บนเครื่องเดียวกันกับ apache2 ไฟล์ proxy.conf จึงได้ตามนี้
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <ifmodule mod_proxy.c> ProxyRequests Off <proxy *> AddDefaultCharset off Order deny,allow #Deny from all Allow from all </proxy> ProxyTimeout 30 ProxyVia On ProxyPass /webcam/live/1 http://localhost:8001 ProxyPass /webcam/config/1 http://localhost:8000/1/config/list ProxyPass /webcam/live/2 http://localhost:8002 ProxyPass /webcam/config/2 http://localhost:8000/2/config/list ProxyPass /webcam/live/3 http://localhost:8003 ProxyPass /webcam/config/3 http://localhost:8000/3/config/list ProxyPass /webcam/live/4 http://localhost:8004 ProxyPass /webcam/config/4 http://localhost:8000/4/config/list </ifmodule> |
เสร็จขั้นตอนด้านบนแล้ว ก็ลองสั่งให้ apache2 reload ดู ถ้าไม่มีปัญหาลองสั่ง apache2 -M ควรจะเห็น โมดูล proxy_module, proxy_http_module ถูกโหลดขึ้นมา
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | Loaded Modules: core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (static) so_module (static) actions_module (shared) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) php5_module (shared) proxy_module (shared) proxy_http_module (shared) rewrite_module (shared) setenvif_module (shared) ssl_module (shared) status_module (shared) userdir_module (shared) Syntax OK |
เอาล่ะเรียบร้อย ก่อนหน้านั้นการเข้ามาดูทำได้โดยเข้ามาที่ URL เช่น http://wutthiphan.com:8001 , http://wutthiphan.com:8002 , http://wutthiphan.com:8003 , http://wutthiphan.com:8004 โดยมากถ้าที่ไหนมีไฟร์วอลล์มักจะโดนบล๊อก หลังจากทำขั้นตอนข้างบนนี้แล้วการเข้ามาดูจะสามารถเข้ามาดูผ่าน URL เช่น http://wutthiphan.com/webcam/live/1 , http://wutthiphan.com/webcam/live/2 , http://wutthiphan.com/webcam/live/3 , http://wutthiphan.com/webcam/live/4
ได้อย่างนี้ อยู่ที่ไหนก็ดูได้แล้วครับ (ขอให้มีอินเตอร์เน็ตนะครับ) ลองเข้าไปดูที่ใช้งานอยู่ได้เลยครับ
กล้องตังที่1 , กล้องตัวที่2 , กล้องตัวที่3 และ กล้องตัวที่4

คอมเม้นท์ล่าสุด