如何重定向到默认主机名
我想要类似的东西:
“http://www.anyhostname.com”==> “http://192.168.0.1”
即我想将“192.168.0.1”以外的任何请求重定向到“http://192.168.0.1”
我使用Lighttpd作为我的网络服务器,使用dnsmasq作为我的DNS服务器。
I want something like:
"http://www.anyhostname.com" ==> "http://192.168.0.1"
i.e. I want to redirect any request other than "192.168.0.1" to "http://192.168.0.1"
I am using Lighttpd as my webserver and dnsmasq as my DNS server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想知道您是否正在执行透明代理 - 如果是这样,可能会有更好的机制来完成你想做的事情,而不是仅仅按照你概述的目标去做。
但如果你想继续走这条路,我认为你可以使用lighttpd的
mod_evhost< /code>
轻松使用默认站点配置的工具:
如果您有想要处理的特定主机名,您可以将它们添加到
/etc/hosts
和您的dnsmasq将为他们服务。如果您想要处理数百个主机/域,那么这会起作用,但如果您想处理所有,那么 dnsmasq 可能不是正确的工具。
我知道 PowerDNS 的 PipeBackend 可用于轻松给出相同的答案,无论 DNS 如何问题;这样,您可以轻松拦截请求并专门处理部分或全部请求。这样,您就可以为每个请求、某些请求或任何您可以编程的请求应答
192.168.0.1
。I have to wonder if you're doing transparent proxying -- if so, there may be better mechanisms to accomplish what you want to do than literally doing what you outlined as your goal.
But if you want to keep going this route, I think you can use lighttpd's
mod_evhost
facility to easily use a default site configuration:If you have specific hostnames that you want to handle, you can add them to
/etc/hosts
and yourdnsmasq
will serve them. This would work if you had a few hundred hosts/domains that you wanted to handle, but if you wanted to handle everything, then dnsmasq may not be the right tool.I know that PowerDNS's PipeBackend can be used to easily give the same answer regardless of DNS question; this way, you could easily intercept requests and handle some or all requests specially. This way, you could answer
192.168.0.1
for every request, for some requests, or anything you can program.好吧,我解决了问题。将解决方案发布在这里,希望它对将来的人有所帮助...
我通过修改lighttpd.conf 文件解决了这个问题。我在lighttpd.conf 文件中添加了以下内容:
谢谢大家的宝贵时间。干杯!
Okay, I solved the problem. Posting the solution here back with hope that it helps somebody in the future...
I solved this by modifying the lighttpd.conf file. I added the following inside my lighttpd.conf file:
Thank you everybody for your time. Cheers!