正在使用 Centos 7 上的标准 discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub 安装过程,但是:
使用 nc 测试端口 80 和 443 上的网络连接如下:
echo -e "HTTP/1.1 200 OK\n\n $VERIFY" | nc -w 4 -l -p $PORT >/dev/null 2>&1 &
if curl --proto =http -s $HOST:$PORT --connect-timeout 3 | grep $VERIFY >/dev/null 2>&1; then
:
但是 nc 失败并显示:
nc: cannot use -p and -l
导致设置脚本报告这些端口不可用。
man nc 说:
-l Listen for an incoming connection rather than initiating a connection to a remote host. Cannot be used together with any of the options -psxz. Additionally, any timeouts specified
with the -w option are ignored.
这可能是 nc 版本问题,我看到 nc linux command man page 没有说这两个选项有任何冲突。我的 netcat 可以监听,但只能使用
nc -w 4 -l <IP 地址> <端口号>
无法让 netcat 告诉我它的版本号 ![]()