ข้ามไปยังเนื้อหาหลัก

กำหนดค่า proxy และข้อยกเว้นบน Windows

คู่มือนี้อธิบายวิธีกำหนดค่า proxy และข้อยกเว้นการ bypass บนWindowsโดยให้ความสำคัญกับการกำหนด proxy แบบอิง IPและความเข้ากันได้ของแอป WebSocket.

แอปทั่วไปที่อาศัย WebSockets:

  • Slack
  • Figma
  • Lucidchart

สิ่งเหล่านี้อาจล้มเหลวเมื่อถูกส่งผ่านพร็อกซี เช่น Squid ซึ่งไม่รองรับการเชื่อมต่อwss://.


สคริปต์นี้ทำอะไร

  • ตั้งค่าที่อยู่ IP ของพร็อกซีทั้งระบบผ่าน PowerShell
  • ใช้ข้อยกเว้นสำหรับแอปของผู้ใช้ (WinINET) และบริการของระบบ (WinHTTP)
  • ป้องกันการกำหนดเส้นทางผ่านพร็อกซีสำหรับแอปที่ใช้ WebSocketและบริการของ Microsoft
  • รองรับการปรับใช้ผ่านIntune, GPO หรือการรันสคริปต์ด้วยตนเอง

ขั้นตอนการกำหนดค่าด้วยตนเอง

  1. เปิด Control PanelInternet Options.
  2. ไปที่แท็บ ConnectionsLAN Settings.
  3. เปิดใช้งาน Use a proxy server.
  4. Set:
    • Address = 192.168.1.10
    • Port = 8080
  5. คลิก Advanced จากนั้นเพิ่มโดเมนด้านล่างลงในรายการ Exceptions.
  6. นำไปใช้และบันทึก

วิธีแบบสคริปต์ (PowerShell)

# Define proxy IP and port
$proxyIP = "http://192.168.1.10:8080"

# Define proxy bypass list
$bypassList = "localhost;127.0.0.1;*.microsoftonline.com;*.core.windows.net;*.slack.com;*.figma.com;*.lucidchart.com;*.lucid.app;*.github.com;copilot-proxy.githubusercontent.com"

# Apply proxy for system services
netsh winhttp set proxy $proxyIP ";$bypassList"

# Apply proxy for user apps
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 1
Set-ItemProperty -Path $regPath -Name ProxyServer -Value $proxyIP
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value $bypassList