Apach2.2卷曲工作,而不是Netcat

时间:2015-10-20 12:55:28

标签: curl netcat apache2.2

我试图在我的服务器上安装mod_status。我使用Apache 2.2并使用此配置:

<IfModule mod_status.c>
    Listen 8001
    ExtendedStatus On
    <VirtualHost *:8001>
        <Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from localhost ip6-localhost ::1 127.0.0.1
        </Location>
    </VirtualHost>
</IfModule>

当我使用curl时,我有正确的输出: curl http://127.0.0.1:8001/server-status?auto

Total Accesses: 4519
Total kBytes: 128320
CPULoad: 10.6216
Uptime: 962
[...]

当我使用netcat时,它失败了(没有输出):

echo 'GET /server-status?auto HTTP/1.1' | nc localhost 8001
echo -e "GET /server-status?auto\r\n" | nc localhost 8001
echo -e "GET /server-status?auto HTTP/1.1\r\n" | nc localhost 8001
echo -e "GET /server-status?auto HTTP/1.0\r\n" | nc localhost 8001
echo -e "GET http://localhost:8001/server-status?auto HTTP/1.0\r\n" | nc localhost 8001
echo -e "GET http://localhost:8001/server-status?auto\r\n" | nc localhost 8001
echo "GET http://localhost:8001/server-status?auto" | nc localhost 8001
printf "GET http://localhost:8001/server-status?auto\r\n" | nc localhost 8001
printf "GET /server-status?auto\r\n" | nc localhost 8001
echo -ne "GET /server-status?auto\r\n\r\n" |nc localhost 8001
echo -ne "GET /server-status?auto HTTP/1.1\r\n\r\n" |nc localhost 8001
echo -ne "GET /server-status?auto HTTP/1.1\r\n" |nc localhost 8001
printf "GET /server-status?auto\r\n"
printf "GET /server-status?auto\n"|nc localhost 8001
echo -ne "GET /server-status?auto HTTP/1.1\r\nUser-Agent: netcat\r\nHost: localhost:8001\r\nAccept: */*\r\n" | netcat 127.0.0.1 8001
echo -ne "GET /server-status?auto HTTP/1.1\r\nUser-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15\r\nHost: localhost:8001\r\nAccept: */*\r\n" | netcat 127.0.0.1 8001

但是,当我执行nc 127.0.0.1 8001并输入GET /server-status?auto +输入提示时,它会有效...

有什么问题?

谢谢你, -G。

1 个答案:

答案 0 :(得分:1)

我认为在获得回复之前netcat退出,当我使用-q1时它会起作用:echo "GET /server-status" | nc -q1 127.0.0.1 8001

man nc: 在stdin上EOF之后-q,等待指定的秒数然后退出。如果秒是负数,则永远等待。

相关问题