搭建nginx web服务,无意中设置监听端口6666,出现如下错误:
Chrome:
nginx:
$ nginx -v
nginx version: nginx/1.16.1
nginx.conf:
server {
listen 6666;
location / {
root /home/test1280/test1280-gitbook/_book/;
index index.html;
}
}
curl访问6666端口,成功:
$ curl -I http://127.0.0.1:6666/
HTTP/1.1 200 OK
Server: test1280
Date: Wed, 21 Jul 2021 10:41:13 GMT
Content-Type: text/html
Content-Length: 10964
Last-Modified: Wed, 21 Jul 2021 09:38:54 GMT
Connection: keep-alive
ETag: "60f7eb2e-2ad4"
Accept-Ranges: bytes
Chrome访问6666端口,失败:ERR_UNSAFE_PORT。
Chrome打开调试F12:
注意,报错信息是ERR_UNSAFE_PORT,不安全端口。
经查,是Chrome自身限制,访问某些受限的端口将报错ERR_UNSAFE_PORT。
参考:
https://superuser.com/questions/188006/how-to-fix-err-unsafe-port-error-on-chrome-when-browsing-to-unsafe-ports
附表:Chrome unsafe port
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
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
139, // netbios
143, // imap2
179, // BGP
389, // ldap
465, // smtp+ssl
512, // print / exec
513, // login
514, // shell
515, // printer
526, // tempo
530, // courier
531, // chat
532, // netnews
540, // uucp
556, // remotefs
563, // nntp+ssl
587, // stmp?
601, // ??
636, // ldap+ssl
993, // ldap+ssl
995, // pop3+ssl
2049, // nfs
3659, // apple-sasl / PasswordServer
4045, // lockd
6000, // X11
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]
解决办法:
1.修改后端服务(nginx)监听端口,使用任意不在上述列表中的端口
2.修改Chrome启动参数、配置(请自行查找)
我直接修改端口改成8090,访问成功:
server {
listen 8090;
location / {
root /home/test1280/test1280-gitbook/_book/;
index index.html;
}
}
$ nginx -s reload
1.https://superuser.com/questions/188006/how-to-fix-err-unsafe-port-error-on-chrome-when-browsing-to-unsafe-ports
2.https://thegeekpage.com/err-unsafe-port/
3.https://blog.csdn.net/testcs_dn/article/details/39186225
4.https://blog.csdn.net/dongzibin/article/details/80779089