简体   繁体   English

用于测试 cgi-bin 的最小 http 服务器

[英]Minimal http server for testing cgi-bin

I have developed and maintain a web application which acts as a front end for some scrips in cgi-bin which in turn call C programs on the server.我开发并维护了一个 web 应用程序,它充当 cgi-bin 中某些脚本的前端,这些脚本又调用服务器上的 C 程序。 The web server is Apache2, hosted both on my office Linux box for testing and on Amazon ECC for the real deployment. Web 服务器是 Apache2,托管在我办公室的Linux 机器上以进行测试,并托管在 Amazon ECC 上以进行实际部署。

My problem is that I'm off travelling, mostly without any internet connection and with only a small portable linux machine, yet I want to develop the next release of the web pages, scripts, data sets and programs.我的问题是我正在旅行,大部分时间没有任何互联网连接,只有一台小型便携式 linux 机器,但我想开发网页、脚本、数据集和程序的下一个版本。 Testing static web pages is no issue but testing pages which call server-side cgi-bin scripts is always problematic, so my idea is to put a minimal http server on the portable linux box (ubuntu 14.04) which will allow the server and client to be on the same machine without any internet (and maybe with just a socket) in-between.测试静态网页没有问题,但测试调用服务器端 cgi-bin 脚本的页面总是有问题,所以我的想法是在便携式 linux 机器(ubuntu 14.04)上放置一个最小的 http 服务器,这将允许服务器和客户端在同一台机器上,中间没有任何互联网(也许只有一个套接字)。

Of course I can and do test scripts and programs directly, but this does not exercise features such as handling top-bit set characters in $POST_DATA or setting and retrieving cookies so would inevitably result in some divergence of code-base.当然,我可以直接测试脚本和程序,但这不会执行诸如处理 $POST_DATA 中的顶级设置字符或设置和检索 cookie 等功能,因此将不可避免地导致代码库的一些分歧。

So:所以:

  1. Is this way sensible or is there a better or simpler means to do what I want?这种方式是明智的还是有更好或更简单的方法来做我想做的事?

  2. If it is sensible, what hppt server would you recommend?如果明智,您会推荐什么hppt服务器? I thought of miniWeb but have no experience of it.我想到了 miniWeb,但没有经验。

PS: I'm expert in the the (maths of the) server-side programs but have much less experience as an apache sysadmin. PS:我是服务器端程序(数学)方面的专家,但作为 apache 系统管理员的经验要少得多。

For many things this is sufficient:对于很多事情,这已经足够了:

python3 -mhttp.server --cgi

Unfortunately, it's so minimal, that it doesn't support stuff like setting the HTTP Status: https://bugs.python.org/issue10487不幸的是,它太小了,它不支持设置 HTTP 状态之类的东西: https : //bugs.python.org/issue10487

I'm not using lighttpd because I don't want to have to write a configuration file.我没有使用 lighttpd,因为我不想编写配置文件。 Another minimal server that can be used is mini-httpd:另一个可以使用的最小服务器是 mini-httpd:

sudo apt install mini-httpd
/usr/sbin/mini_httpd -D -p 8000 -c 'cgi-bin/*'

The -D option keeps the server in the foreground instead of daemonizing it. -D选项将服务器保持在前台而不是守护它。 The -p option is the port and -c is a pattern for my cgi scripts. -p选项是端口, -c是我的 cgi 脚本的模式。

I also found that the built-in webserver of busybox can handle cgi scripts just fine:我还发现busybox内置的webserver可以很好地处理cgi脚本:

busybox httpd -p 8000 -f

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM