วันจันทร์ที่ 23 มิถุนายน พ.ศ. 2557

webmatrix และ iis express วิธีทำเข้าถึง เวปไซต์ของเรา จาก ภายในเครือข่ายหรือมือถือผ่าน wifi (how to set iis express can access by my network e.g. mobile)


วิธีที่ทำให้ เข้าถึง website ที่อยู่บน iis express (ของผม เป็น iis8 expressมาพร้อมกับ webmatrix)
โดยผ่านทางเครือข่าย หรือ มือถือเพื่อทดสอบโค็ด และแสดงผล ดังภาพตัวอย่าง2ภาพล่าง


1.ตั้ง website settings ให้เป็นหมายเลขไอพี (ถ้าตั้งเป็นชื่อ จะมีปัญหาจากการเข้าถึงโดยมือถือ เพราะมันจะฟ้อง invalid hostname ถึงแม้คุณจะใส่addressที่มือถือเป็นตัวเลขไอพีก็ตาม มันก็ยังฟ้อง และข้อดีอีกอย่างของการใช้ไอพี คือคุณไม่ต้อง root มือถือแอนดรอย์ของคุณเพื่อความปลอดภัย แต่ถ้าอยากทำ ให้เข้าถึงได้ โดยใช้ ชื่อ แทน ไอพีดังภาพ ซึ่งต้องเพิ่มขั้นตอน การ root เครื่อง ต้อง root ให้สำเร็จก่อนแล้วตามด้วย แก้ไขไฟล์ hosts ใน /system/etc/hosts เป็น 192.168.1.10 myweb เข้าไปโดยใช้ดาวนโหลด app ใน google play ชื่อ hosts editor ไปอีกบทความครับตามลิงค์นี้http://joegtec.blogspot.com/2014/06/iis-express-wifi-url-httpmyweb60000.html
)
เมื่อทำแล้วลองทดสอบเข้าจากเครื่องที่ลง iis ก่อน ว่าเปิดเวปเราตาม url ใหม่ที่กำหนดได้หรือเปล่า ถ้าเข้าได้อาจจะเว้นข้อ3ไม่ต้องทำก็ได้ครับ
2.ทำการเพิ่ม เวปไซต์เราใน http.sys โดยเข้าไปเพิ่มโดย ใน powershell หรือใน หน้าต่าง dos ก็ได้ ในที่นี้ผมใช้ powershell วิธีโดยตามภาพ ใน เมนู runที่ start


พิมพ์ข้อความใน powershell ดังนี้
netsh http add urlacl url=http://192.168.1.10:60000/ user=Everyone
ดังภาพ


ผลลัพธ์ ถ้า ok ก็เรียบร้อย
3.โดยปรกติเมื่อคุณกำหนด ตามข้อ1 webmatirx จะเปลี่ยน ค่าในไฟล์ applicationhost.config อัตโนมัติ แต่ถ้าไม่เปลี่ยนก็ทำเอง โดยไปที่ C:\Users\Administrator\Documents\IISExpress\config\applicationhost.config
ตรง Administrator ก็เปลี่ยนเป็น user ของคุณเอง อย่าลืมต้องมีสิทธิเป็น Administrator นะครับ

ตามรูปภาพ แถบสีฟ้าแก้ไขเป็น <binding protocol="http" bindingInformation="*:60000:192.168.1.10" />




4. พิมพ์คำสั่งนี้ใน หน้าต่าง powershell เพื่อไม่ให้ถูกบล็อคโดย firewall
netsh advfirewall firewall add rule name="IIS Express (non-SSL)" action=allow protocol=TCP dir=in localport=60000

ดังภาพ

5.สั่ง restart iis สักครั้ง อาจไปทำในหน้าต่าง webmatrix ก้ได้คับ หรือตรง taskbar สั่ง stop และก็เริ่ม iis ใหม่อีกครั้ง วิธีการรัน iis ใหม่อีกครั้งทำได้หลายวิธี แบบไม่ยุ่งยากก็ปิดและเปิด webmatrix อีกครั้ง iis ก็จะเปิดขึ้นมาเอง หรือเข้าไปที่ ดังภาพ คลิกเปิด iisexpress.exe





จบ..
-------------------------------------------------------------------------------------------------------





ที่มาhttp://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx


Hello, I am running Windows 7 SP1. I followed the following steps:


Step 1


netsh http add urlacl url=http://192.168.1.100:8000/ user=Everyone


netsh http add urlacl url=https://192.168.1.100:44300/ user=Everyone


Step 2


applicationhost.config


<site name="WebSite1" id="1">


<application path="/">


<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />


</application>


<bindings>


<binding protocol="http" bindingInformation="*:8000:192.168.1.100" />


<binding protocol="https" bindingInformation="*:44300:192.168.1.100" />


</bindings>


</site>


Step 3


netsh advfirewall firewall add rule name="IIS Express (non-SSL)" action=allow protocol=TCP dir=in localport=8000


netsh advfirewall firewall add rule name="IIS Express (SSL)" action=allow protocol=TCP dir=in localport=44300


Then I procedded to run WebMatrix without elevated privileges. It binds to 192.168.1.100 without any errors, and the page loads just fine. However when I attempt to access it from my external ip address, the page times out despite having the ports forwarded to my ip and even putting myself in dmz.

ไม่มีความคิดเห็น:

แสดงความคิดเห็น