lighttpd 配置 $HTTP[“主机”]

发布于 2024-08-22 05:36:19 字数 325 浏览 9 评论 0原文

我正在尝试配置我的 lighttpd 服务器以使用 fastcgi 模块。我(盲目地)遵循的配方要求lighttpd.conf中的以下行

$HTTP["host"] =~ "(^|\.)example\.com$" {

我在虚拟专用服务器上运行,并且我没有域名,只有IP。所以我假设我必须用我的 IP 替换域名 - 比方说 100.101.102.103

这不起作用,

$HTTP["host"] =~ "(^|\.)100\.101\.102\.103$" {

几种变体也不起作用。

I am trying to configure my lighttpd server to use a fastcgi module. The recipe I am following ( blindly ) calls for the following line in lighttpd.conf

$HTTP["host"] =~ "(^|\.)example\.com$" {

I am running on a virtual private server, and I do not have a domain name, just an IP. So I assume that I have to replace the domain name with my IP - let's say 100.101.102.103

This does not work

$HTTP["host"] =~ "(^|\.)100\.101\.102\.103$" {

Neither does several variations.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三岁铭 2024-08-29 05:36:19

您可以通过查看 lighttpd 的访问日志来确定任何给定请求的 $HTTP["host"] 的值(它是标准日志行上的第二个条目;如果请求不存在,它将显示为“-”)指定一项)。

如果日志显示您有一个固定的 IP 地址,那么这是一个更清晰的测试:(

$HTTP["host"] == "100.101.102.103" {

尽管您使用的正则表达式应该有效)。

然而,这里可能引起混淆的事实是 $HTTP["host"] 设置为传入请求中“Host:”标头的值,因此它完全处于客户端(浏览器、脚本等)的控制之下提出请求。知道你正在测试的 URL 是什么会让事情变得更清楚。

You can determine what the value of $HTTP["host"] is for any given request by looking in lighttpd's access log (it's the second entry on a standard log line; it'll show as "-" if the request didn't specify one).

If the log shows you have a fixed IP address, this is a much cleaner test for it:

$HTTP["host"] == "100.101.102.103" {

(though the regular expression you were using should have worked).

What's probably causing confusion here however is the fact that $HTTP["host"] is set to the value of the "Host:" header in the incoming request so it's completely under the control of the client (browser, script, whatever) that's making the request. Knowing what the URL is you are testing with would clarify things a lot.

红颜悴 2024-08-29 05:36:19

查找一下您的 IP 地址,是否真的没有对应的 DNS 名称?他们通常至少提供一个子域。

最后,你可以只输入“*”,它就会响应所有内容。

你使用fastcgi吗?它确实有所作为。

Do a lookup on your IP address, is there really no DNS name for it? They sually provide a subdomain at the very least.

Lastly, you can just put "*" and it will respond to everything.

Are you using fastcgi? it really makes a difference.

凉宸 2024-08-29 05:36:19

我发现这有效:

$SERVER["socket"] == "0.0.0.0:8000" {

I found that this works:

$SERVER["socket"] == "0.0.0.0:8000" {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文