实在无果,求段 Nginx 过滤网址白名单配置

2015-07-17 02:29:54 +08:00
 Yingc
因分享了公共代理,导致那些人乱上一些不良网站,已经被发邮件投诉。请求各位帮帮忙,就是想允许列表里的网址通过访问,而不在允许列表里的就重定向到某页面,大概要允许上千个网址。
真的很需要
6301 次点击
所在节点    NGINX
18 条回复
Septembers
2015-07-17 04:46:19 +08:00
无条件重定向DNS流量到本地
然后自建个DNS 需要的域就转发就可以了
DreaMQ
2015-07-17 04:48:10 +08:00
简单的说,设置并强制指定(iptables之类)OpenDNS,然后去 opendns.com 注册你的服务器 IP 并过滤域名
oott123
2015-07-17 08:23:06 +08:00
squid/acl 呀
FifiLyu
2015-07-17 09:05:09 +08:00
https://github.com/fifilyu/module-http-whitelist

用 iptables 的 string 模块做一个白名单即可。
Yingc
2015-07-17 10:04:25 +08:00
@FifiLyu 感谢
Yingc
2015-07-17 10:53:42 +08:00
@FifiLyu 我的系统市Debian7无法编译文件
Yingc
2015-07-17 11:00:42 +08:00
make -C /lib/modules/3.2.0-4-686-pae/build/ M=/root/module-http-whitelist modules
make: *** /lib/modules/3.2.0-4-686-pae/build/: No such file or directory. Stop.
make: *** [all] Error 2
Yingc
2015-07-17 11:30:35 +08:00
debian下,无法安装 kernel-devel
FifiLyu
2015-07-17 11:42:53 +08:00
@Yingc 我下午装一个debian7测试一下。 应该是依赖包没安装上的问题。

你的情况建议先用 iptables string 模块。直接iptables即可满足你了。不需要用我这个Linux内核模块。

用内核模块适合大量请求访问的情况使用
Yingc
2015-07-17 12:24:52 +08:00
@FifiLyu 感觉你这个方便点,我尝试sudo apt-get install linux-headers-$(uname -r)后,虽然能编译但还是有错误,出来的东西无法加载,你是怎么安装这个的。
yangxin0
2015-07-17 12:34:54 +08:00
用openresty在acces阶段执行一个lua脚本即可,url 白明白可以存在redis或者mysql中
FifiLyu
2015-07-17 13:33:30 +08:00
@Yingc 我在 Debian 7 上测试了,编译和运行ok。

安装依赖包:
sudo apt-get install linux-headers-`uname -r`
FifiLyu
2015-07-17 13:45:20 +08:00
@Yingc

初始化配置文件

$ sudo mkdir /etc/http_whitelist
$ sudo touch /etc/http_whitelist/host /etc/http_whitelist/network

详情请看:

初始化配置文件
https://github.com/fifilyu/module-http-whitelist#%E5%88%9D%E5%A7%8B%E5%8C%96%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6
Yingc
2015-07-17 15:31:03 +08:00
Yingc
2015-07-17 15:31:53 +08:00
@FifiLyu
root@sf:~# sudo mkdir /etc/http_whitelist
root@sf:~# sudo touch /etc/http_whitelist/host /etc/http_whitelist/network
root@sf:~# sudo apt-get install linux-headers-'uname -r'
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-uname -r
root@sf:~# cd module-http-whitelist
root@sf:~/module-http-whitelist# sudo insmod http_whitelist.ko
root@sf:~/module-http-whitelist# lsmod
Module Size Used by
http_whitelist 12997 0
Yingc
2015-07-17 15:32:29 +08:00
原来是要先创建目录、文件。
FifiLyu
2015-07-17 17:20:50 +08:00
sudo apt-get install linux-headers-`uname -r`

uname -r 不是用单引号,而是反勾号。是键盘左边的数字“1”旁边的符号。
Yingc
2015-07-17 18:30:59 +08:00
@FifiLyu 已经加载上了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/206270

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX