Redirect lighttpd-ip地址重定向

Redirect lighttpd-ip地址重定向,redirect,lighttpd,http-redirect,Redirect,Lighttpd,Http Redirect,我正在尝试将IP地址作为URL重定向到正式的主机名作为URL: debug.log-request-handling = "enable" debug.log-request-header = "enable" debug.log-response-header = "enable" debug.log-ssl-noise = "enable" debug.log-condition-handling = "enable" $HTTP["host"] == "192.168.1.20

我正在尝试将IP地址作为URL重定向到正式的主机名作为URL:

debug.log-request-handling = "enable" 
debug.log-request-header = "enable" 
debug.log-response-header = "enable" 
debug.log-ssl-noise = "enable" 
debug.log-condition-handling = "enable" 

$HTTP["host"] == "192.168.1.20" {
    url.redirect = ( ".*" => "http://pihole.home.lan/" )
}
但它不起作用。相关日志条目:

2019-02-26 13:01:35: (request.c.436) fd: 10 request-len: 331 \nGET / HTTP/1.1\r\nHost: 192.168.1.20\r\nUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\n\r\n 
2019-02-26 13:01:35: (response.c.261) run condition 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.557) SERVER["socket"] ( :80 ) compare to  [::]:80 
2019-02-26 13:01:35: (configfile-glue.c.615) 1 (uncached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.557) HTTP["url"] ( / ) compare to  ^/admin/ 
2019-02-26 13:01:35: (configfile-glue.c.615) 2 (uncached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.350) go parent global/HTTPurl=~^/admin/ 
2019-02-26 13:01:35: (configfile-glue.c.622) 2 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.615) 3 (uncached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.557) HTTP["url"] ( / ) compare to  ^/admin/\.(.*) 
2019-02-26 13:01:35: (configfile-glue.c.615) 4 (uncached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.557) HTTP["host"] ( 192.168.1.20 ) compare to  192.168.1.20 
2019-02-26 13:01:35: (configfile-glue.c.615) 5 (uncached) result: true 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.557) HTTP["host"] ( 192.168.1.20 ) compare to  pihole($|\.home\.lan) 
2019-02-26 13:01:35: (configfile-glue.c.615) 6 (uncached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.350) go parent global/HTTPhost=~pihole($|\.home\.lan) 
2019-02-26 13:01:35: (configfile-glue.c.622) 6 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.615) 7 (uncached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.350) go parent global/HTTPhost=~pihole($|\.home\.lan) 
2019-02-26 13:01:35: (configfile-glue.c.622) 6 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.615) 8 (uncached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.350) go parent global/HTTPhost=~pihole($|\.home\.lan)/HTTPscheme==http 
2019-02-26 13:01:35: (configfile-glue.c.622) 8 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.615) 9 (uncached) result: skipped 
2019-02-26 13:01:35: (response.c.350) -- splitting Request-URI 
2019-02-26 13:01:35: (response.c.351) Request-URI     :  / 
2019-02-26 13:01:35: (response.c.352) URI-scheme      :  http 
2019-02-26 13:01:35: (response.c.353) URI-authority   :  192.168.1.20 
2019-02-26 13:01:35: (response.c.354) URI-path (raw)  :  / 
2019-02-26 13:01:35: (response.c.355) URI-path (clean):  / 
2019-02-26 13:01:35: (response.c.356) URI-query       :   
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 1 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 2 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 3 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 4 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 5 (cached) result: true 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 6 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 7 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 8 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 9 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 1 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 2 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 3 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 4 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 5 (cached) result: true 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 6 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 7 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 8 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 9 (cached) result: skipped 
2019-02-26 13:01:35: (mod_access.c.148) -- mod_access_uri_handler called 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 1 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 2 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 3 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 4 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 5 (cached) result: true 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 6 (cached) result: false 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 7 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 8 (cached) result: skipped 
2019-02-26 13:01:35: (configfile-glue.c.694) === start of condition block === 
2019-02-26 13:01:35: (configfile-glue.c.622) 9 (cached) result: skipped 
2019-02-26 13:01:35: (response.c.122) Response-Header: \nHTTP/1.1 401 Unauthorized\r\nContent-Type: text/html\r\nContent-Length: 351\r\nDate: Tue, 26 Feb 2019 21:01:35 GMT\r\nServer: lighttpd/1.4.45\r\n\r\n 
日志的这一部分显示主机as 192.168.1.20的测试返回true:

HTTP["host"] ( 192.168.1.20 ) compare to  192.168.1.20
5 (uncached) result: true 
但是,重定向似乎没有发生,下一个操作是返回未经授权的401


我想我遗漏了一些基本信息。

mod_auth可能在mod_重定向之前加载到配置文件中,因此身份验证要求在重定向之前应用于请求。这通常是非常理想的行为,以避免将有关重定向的信息泄漏给未经授权的用户。如果要首先执行重定向,请设置应用重定向的条件,并将身份验证要求应用于所有其他内容

$HTTP["host"] == "192.168.1.20" {
    url.redirect = ( "" => "http://pihole.home.lan/" )
}
else {
    auth.require = ( ... )
}

基于您的多篇文章,很明显您正在尝试创建一个比您的基本理解更复杂的配置。在发布越来越多的问题之前,请测试一个简单的配置。一旦你成功地完成了一个“强”单、简单的<强>事物,那么你就应该考虑把它添加到你现有的配置中,然后再测试。如果行得通,那太好了。如果它不起作用,请在发布更多问题和让人们猜测您的配置之前,自己花一些精力进行故障排除,我会注意到您没有提供。你在互联网上的同龄人没有洞察力。我们通常更擅长于故障排除(例如,遵循刚才提到的简单、基本的步骤)。

mod\u auth可能在mod\u重定向之前加载到配置文件中,因此在重定向之前,身份验证要求会应用到请求中。这通常是非常理想的行为,以避免将有关重定向的信息泄漏给未经授权的用户。如果要首先执行重定向,请设置应用重定向的条件,并将身份验证要求应用于所有其他内容

$HTTP["host"] == "192.168.1.20" {
    url.redirect = ( "" => "http://pihole.home.lan/" )
}
else {
    auth.require = ( ... )
}

基于您的多篇文章,很明显您正在尝试创建一个比您的基本理解更复杂的配置。在发布越来越多的问题之前,请测试一个简单的配置。一旦你成功地完成了一个“强”单、简单的<强>事物,那么你就应该考虑把它添加到你现有的配置中,然后再测试。如果行得通,那太好了。如果它不起作用,请在发布更多问题和让人们猜测您的配置之前,自己花一些精力进行故障排除,我会注意到您没有提供。你在互联网上的同龄人没有洞察力。我们通常更擅长故障排除(例如,遵循刚才提到的简单、基本的步骤)。

再次感谢您的帮助-我现在正在消化它的所有方面。再次感谢您的帮助-我现在正在消化它的所有方面。