lighttpd-IP地址的重定向 [英] lighttpd - redirect of ip address

查看:183
本文介绍了lighttpd-IP地址的重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将ipaddress-as-URL重定向为URL的正式主机名:

I'm trying to redirect an ipaddress-as-URL to the formal hostname as 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/" )
}

但是它不起作用.相关日志条目:

But it doesn't work. Relevant log entries:

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 

日志的此部分显示对HOST的测试,结果为192.168.1.20,返回true:

This part of the log shows the test for HOST as 192.168.1.20 returning true:

HTTP["host"] ( 192.168.1.20 ) compare to  192.168.1.20
5 (uncached) result: true 

但是,重定向似乎没有发生,下一步是返回未经授权的401.

However, the redirect doesn't seem to take place, and the next action is return unauthorized 401.

我想我缺少一些基本知识.

I think I am missing something basic.

推荐答案

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

mod_auth is likely loaded before mod_redirect in your config file and so the authentication requirement is applied to the request before the redirect. This is often very desirable behavior in order to avoid leaking information about the redirect to unauthorized users. If you want to perform the redirect first, then set a condition on which to apply the redirect, and apply the authentication requirement to everything else.

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

根据您的多篇文章,很明显,您正在尝试创建一个比您的基本理解还要复杂的配置.在发布越来越多的越来越多的问题之前,请使用您要尝试的方法测试简单配置.一旦可以单独完成简单的工作,那么您才应该考虑将其添加到现有配置中,然后再次进行测试.如果可行,那就太好了.如果它不起作用,请在发布更多问题并使人们猜测您的配置之前自行进行故障排除,我会注意到您还没有提供.您在互联网上的同龄人并非千里眼.我们通常在故障排除方面会更好(例如,按照刚才提到的简单的基本步骤进行操作).

Based on your multiple posts, it is clear that you are trying to create a configuration more complex than your basic understanding. Before posting more and more and more and more and more and more questions, please test a simple configuration with what you are trying to do. Once you get it working to do a single, simple thing all by itself, only then should you consider adding it to your existing configuration, and testing again. If it works, great. If it does not work, please spend some effort troubleshooting on your own before posting more questions and making people guess about your configuration, which I will note that you have not provided. Your peers on the internet are not clairvoyant. We are just often better at troubleshooting (e.g. following the simple, basic steps just mentioned).

这篇关于lighttpd-IP地址的重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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