Busybox

如何使用busybox httpd設置標題

  • January 19, 2021

我正在使用以下命令執行busybox httpd:

busybox httpd -p 80 -h /var/www

它可以工作,但是我需要將記憶體控制標頭設置為無記憶體。

目前我的伺服器僅附加這些標頭:

 HTTP/1.0 200 OK
 Content-type: text/html
 Date: Thu, 28 Jun 2018 06:58:08 GMT
 Connection: close
 Accept-Ranges: bytes
 Last-Modified: Thu, 28 Jun 2018 06:57:43 GMT
 Content-Length: 45

如何配置我的busybox httpd 伺服器以追加

Cache-Control: no-cache

標題?

BusyBox HTTP Daemon (httpd) 網路伺服器是一個自己的簡單網路伺服器實現,沒有廣泛的配置選項,您可以從OpenWRT 配置文件或原始碼的註釋塊中看到httpd.c(第 39-60 行):

* httpd.conf has the following format:
*
* H:/serverroot     # define the server root. It will override -h
* A:172.20.         # Allow address from 172.20.0.0/16
* A:10.0.0.0/25     # Allow any address from 10.0.0.0-10.0.0.127
* A:10.0.0.0/255.255.255.128  # Allow any address that previous set
* A:127.0.0.1       # Allow local loopback connections
* D:*               # Deny from other IP connections
* E404:/path/e404.html # /path/e404.html is the 404 (not found) error page
* I:index.html      # Show index.html when a directory is requested
*
* P:/url:[http://]hostname[:port]/new/path
*                   # When /urlXXXXXX is requested, reverse proxy
*                   # it to http://hostname[:port]/new/pathXXXXXX
*
* /cgi-bin:foo:bar  # Require user foo, pwd bar on urls starting with /cgi-bin/
* /adm:admin:setup  # Require user admin, pwd setup on urls starting with /adm/
* /adm:toor:PaSsWd  # or user toor, pwd PaSsWd on urls starting with /adm/
* /adm:root:*       # or user root, pwd from /etc/passwd on urls starting with /adm/
* /wiki:*:*         # or any user from /etc/passwd with according pwd on urls...
* .au:audio/basic   # additional mime type for audio.au files
* *.php:/path/php   # run xxx.php through an interpreter

您對 BusyBox HTTPd 的選擇:

  • BusyBox HTTP 守護程序是開源的。修改httpd.c添加標頭檔並編譯。
  • 將您的頁面用作cgi 腳本。它可以在開頭有自定義標題。

或者安裝一些更通用的 Web 伺服器:NginxApacheLighttpd

引用自:https://serverfault.com/questions/918602