无法弄清楚如何使用lighttpd接收HTTP请求 [英] Can't figure out how to receive http requests using lighttpd

查看:621
本文介绍了无法弄清楚如何使用lighttpd接收HTTP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行在路由器上的简单lighttpd Web服务器.在它的.conf文件中,我知道我需要设置

I have a simple lighttpd web server running off my router. In it's .conf file I know I need to set

$ HTTP ["querystring"] =〜"cams = on" {远程登录通过托管的poe开关打开摄像头}

$HTTP["querystring"] =~ "cams=on" { telnet to turn on cams via managed poe switch }

我遇到的问题是试图弄清楚如何真正运行它来发送将telnet命令发送到我的poe交换机的脚本.我从来没有做过这样的事情,对于那些不熟悉Web服务的人,我找不到任何帮助.

The issue I am having is trying to figure out how to actually get it to run a script that sends telnet commands to my poe switch. I've never done anything like this and I'm unable to find any help for anyone not angry familiar with web serving.

推荐答案

使用lighttpd可以使用多种方法.最简单的方法之一就是使用CGI. https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModCGI

There are multiple ways to do this with lighttpd. One of the simplest is by using CGI. https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModCGI

server.modules += ( mod_cgi )
$HTTP["query-string"] =~ "cams=on" {
  cgi.assign = ( "" => "/path/to/control-script" )
}

当lighttpd接收带有该查询字符串的请求时,将执行/path/to/control-script. (在网络上搜索有关CGI脚本在环境中会发生什么变化的教程,例如环境变量QUERY_STRING ="cams = on")

Your /path/to/control-script will be executed when lighttpd receives requests with that query string. (Search the web for tutorials on what to expect in the environment for your CGI script, like the environment variable QUERY_STRING="cams=on")

请注意,建议您将脚本限制为某些路径,而不是在对服务器任何其他部分的任何请求上截取该查询字符串.如果脚本以已知路径运行并且可以处理查询字符串中的多个不同命令,则可以省略$ HTTP ["query-string"]条件.

Please note that it is recommended that you restrict the script to certain paths, rather than intercepting that query string on any request to any other part of your server. You can omit the $HTTP["query-string"] condition if your script runs at a known path and can handle multiple different commands in the query string.

server.modules += ( mod_cgi )
$HTTP["url"] =~ "^/control/" {
  $HTTP["query-string"] =~ "cams=on" {
    cgi.assign = ( "" => "/path/to/control-script" )
  }
}

最后,您可能想使用lighttpd mod_auth来限制谁可以访问控制脚本. https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModAuth

Lastly, you probably want to use lighttpd mod_auth to restrict who can access the control script. https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModAuth

这篇关于无法弄清楚如何使用lighttpd接收HTTP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆