浏览器默认非安全端口

#nginx #web端口 今天在添加nginx多个端口访问时无意间使用到了87号端口,发现服务正常启动、端口正常监听,就是无法访问,最开始以为是项目代码有问题,遂更换了一个正常的项目发现仍然不能访问。此时注意到浏览器提示 “错误代码:ERR_UNSAFE_PORT”。经过一番查阅才发现是chrome对部分端口做了限制。默认为不安全端口,进而限制了访问。更换端口为88之后果然一切正常。然后还了解到chrome默认的不安全端口远不止这一个,以下是chrome源码中写死的端口号列表

1, // tcpmux 7, // echo 9, // discard 11, // systat 13, // daytime 15, // netstat 17, // qotd 19, // chargen 20, // ftp data 21, // ftp access 22, // ssh 23, // telnet 25, // smtp 37, // time 42, // name 43, // nicname 53, // domain 69, // tftp 77, // priv-rjs 79, // finger 87, // ttylink 95, // supdup 101, // hostriame 102, // iso-tsap 103, // gppitnp 104, // acr-nema 109, // pop2 110, // pop3 111, // sunrpc 113, // auth 115, // sftp 117, // uucp-path 119, // nntp 123, // NTP 135, // loc-srv /epmap 137, // netbios 139, // netbios 143, // imap2 161, // snmp 179, // BGP 389, // ldap 427, // SLP (Also used by Apple Filing Protocol) 465, // smtp+ssl 512, // print / exec 513, // login 514, // shell 515, // printer 526, // tempo 530, // courier 531, // chat 532, // netnews 540, // uucp 548, // AFP (Apple Filing Protocol) 554, // rtsp 556, // remotefs 563, // nntp+ssl 587, // smtp (rfc6409) 601, // syslog-conn (rfc3195) 636, // ldap+ssl 993, // ldap+ssl 995, // pop3+ssl 1719, // h323gatestat 1720, // h323hostcall 1723, // pptp 2049, // nfs 3659, // apple-sasl / PasswordServer 4045, // lockd 5060, // sip 5061, // sips 6000, // X11 6566, // sane-port 6665, // Alternate IRC [Apple addition] 6666, // Alternate IRC [Apple addition] 6667, // Standard IRC [Apple addition] 6668, // Alternate IRC [Apple addition] 6669, // Alternate IRC [Apple addition] 6697, // IRC + TLS 10080, // chrome 91之后的版本会同样提示“ERR_UNSAFE_PORT”非安全端口 虽然默认了上面这些端口为非安全端口导致不能直接使用,如果非要使用也可以通过如下方法进行绕过限制

右键单击Chrome快捷方式>>选择属性>>在"目标"对应文本框中添加如下参数:

--explicitly-allowed-ports=xxx (xxx为目标端口号)

例如:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --explicitly-allowed-ports=87,6666

不过虽然通过上面的方法可以绕过,但还是建议尽量避免使用这些端口

最后更新于