就是利用OpenBSD 5.6或以上系统的httpd服务器上面弄个页面,任意浏览器访问这台服务器,就自动显示来访者的ip地址
效果类似 访问 http://checkip.amazonaws.com/
完整的配置方法有么?
涉及到chroot slowcgi 等,可供参考的文档如下,当作备忘吧,若没有人回复,将来有时间继续研究。。。
http://protoc.org/blog/2014/11/23/first ... pd-server/
http://en.wikibooks.org/wiki/Guide_to_U ... _Webserver
https://www.ciscodude.net/2014/05/14/op ... t-5-bgplg/
http://www.cgi101.com/book/ch3/text.html
https://snipt.net/bhubbard/display-visi ... s-via-cgi/
http://www.perlmonks.org/?node_id=1110948
OpenBSD 自带httpd显示来访者ip的脚本配置问题
Re: OpenBSD 自带httpd显示来访者ip的脚本配置问题
搞定了,自问自答
-----
OpenBSD显示来访者ip地址和浏览器信息的脚本
编辑脚本
# vi /var/www/cgi-bin/test
#!/bin/sh
echo "Content-type: text/plain"
echo
echo $REMOTE_ADDR
echo $HTTP_USER_AGENT
设置脚本可执行权限
# chmod 0555 /var/www/cgi-bin/test
# ldd /bin/sh
/bin/sh:
Start End Type Open Ref GrpRef Name
000019c10e34a000 000019c10e7cb000 dlib 1 0 0 /bin/sh
在chroot相应目录添加需要的程序
# cp /bin/sh /var/www/bin/
确定程序可执行
# ls -l /var/www/bin/sh
-r-xr-xr-x 1 root daemon 480960 Mar 26 15:04 /var/www/bin/sh
添加恰当的http.conf
# cat /etc/httpd.conf
ext_addr="*"
server "default" {
listen on $ext_addr port 80
location "/cgi-bin/*" {
fastcgi
# The /cgi-bin directory is outside of the document root
root "/"
}
root "/htdocs"
}
添加必须的启动项
# cat /etc/rc.conf.local
httpd_flags=""
slowcgi_flags=""
启动
# /etc/rc.d/slowcgi start
# /etc/rc.d/httpd start
任意浏览器访问服务器
http://A.A.A.A/cgi-bin/test
得到结果
B.B.B.B Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
完整的参考文档
-----
OpenBSD显示来访者ip地址和浏览器信息的脚本
编辑脚本
# vi /var/www/cgi-bin/test
#!/bin/sh
echo "Content-type: text/plain"
echo
echo $REMOTE_ADDR
echo $HTTP_USER_AGENT
设置脚本可执行权限
# chmod 0555 /var/www/cgi-bin/test
# ldd /bin/sh
/bin/sh:
Start End Type Open Ref GrpRef Name
000019c10e34a000 000019c10e7cb000 dlib 1 0 0 /bin/sh
在chroot相应目录添加需要的程序
# cp /bin/sh /var/www/bin/
确定程序可执行
# ls -l /var/www/bin/sh
-r-xr-xr-x 1 root daemon 480960 Mar 26 15:04 /var/www/bin/sh
添加恰当的http.conf
# cat /etc/httpd.conf
ext_addr="*"
server "default" {
listen on $ext_addr port 80
location "/cgi-bin/*" {
fastcgi
# The /cgi-bin directory is outside of the document root
root "/"
}
root "/htdocs"
}
添加必须的启动项
# cat /etc/rc.conf.local
httpd_flags=""
slowcgi_flags=""
启动
# /etc/rc.d/slowcgi start
# /etc/rc.d/httpd start
任意浏览器访问服务器
http://A.A.A.A/cgi-bin/test
得到结果
B.B.B.B Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
完整的参考文档
代码: 全选
参考
http://protoc.org/blog/2014/11/23/first-thoughts-on-the-new-openbsd-httpd-server/
http://en.wikibooks.org/wiki/Guide_to_Unix/BSD/OpenBSD/As_a_Webserver
https://www.ciscodude.net/2014/05/14/openbsd-5-dot-5-bgplg/
http://www.cgi101.com/book/ch3/text.html
https://snipt.net/bhubbard/display-visitors-ip-address-via-cgi/
http://www.perlmonks.org/?node_id=1110948
http://marc.info/?t=142737694500005&r=1&w=2
在线用户
正浏览此版面之用户: 没有注册用户 和 1 访客