中文
VPS/VDS 主机

在 Windows VPS 上开放防火墙端口

在 Windows Defender 防火墙中创建入站规则,允许 HTTP、HTTPS 或自定义端口访问您的 Windows Server VPS。

约 2 分钟阅读

在 Windows 防火墙中开放端口(VPS)

要让 Windows VPS 上的服务(IIS 网站、游戏服务器、API)可以从互联网访问,除了服务商处可能存在的规则之外,通常还需要在 Windows Defender 防火墙中放行该端口。

开始之前

  • 通过远程桌面连接:参见通过 RDP 连接。
  • 了解端口号和协议(TCP 或 UDP)。
  • 只开放您需要的端口(最小权限原则)。

方法 1:图形向导

  1. 打开高级安全 Windows Defender 防火墙(wf.msc)。
  2. 入站规则 → 新建规则…
  3. 端口 → TCP(或 UDP)→ 特定本地端口:例如 80、443 或 8080。
  4. 允许连接。
  5. 选择配置文件(域、专用、公用——在 VPS 上通常需要选择公用)。
  6. 为其起一个清晰的名称,例如 HTTP IIS 80。

方法 2:PowerShell(TCP 80 和 443)

以管理员身份打开 PowerShell:

PowerShell
New-NetFirewallRule -DisplayName "HTTP TCP 80" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow New-NetFirewallRule -DisplayName "HTTPS TCP 443" -Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow

自定义端口示例:

PowerShell
New-NetFirewallRule -DisplayName "MyApp TCP 5000" -Direction Inbound -Protocol TCP -LocalPort 5000 -Action Allow

验证是否有服务在监听

PowerShell
Get-NetTCPConnection -State Listen | Where-Object { $_.LocalPort -eq 80 }

或者:

PowerShell
netstat -ano | findstr :80

安全提示

  • 开放端口会暴露该服务:请保持更新,使用强密码,并尽可能为网站启用 TLS。
  • 如果流量始终无法到达虚拟机,请确认云安全组的设置。

我们的 Windows VPS 提供相同的 8 个地点:Windows VPS 法国、Windows VPS 德国、Windows VPS 荷兰、Windows VPS 英国、Windows VPS 美国、Windows VPS 加拿大、Windows VPS 土耳其和 Windows VPS 香港。同时也提供桌面版本:Windows 10 RDP 和 Windows 11 RDP。

故障排除

  • 仍然无法访问:确保应用程序监听的是 0.0.0.0 或公网接口,而不仅仅是 127.0.0.1。
  • RDP 问题:不要删除系统自带的 RDP 规则;如果被锁定在外,请使用服务商的控制台。

最新教程

及时了解最新的优惠、折扣和特别促销活动。

查看促销

我们使用Cookie

我们使用 Cookie 来衡量和改进本网站。 隐私政策