准备把内网的一个网站放出去,为了b格以及安全性,决定使用代理proxy ssl modsecurity (后面我决定简写为modsec)
ssl 免费证书不难,这里做个广告 https://www.startssl.com/ 免费用一年,可以有一个域名的5个子域名,这部分不难,自己网上看看,稍微麻烦一点的是需要域名的邮箱认证,提供了三个可选邮箱webmaster、postmaster、还有三个什么忘了
下一个做反向代理,开始打算nginx+modsec,结果不开modsec没问题,一开会发现.js文件会被莫名其妙的置空,看到有人在官网反馈问题了,但是官方说那个人提出的问题不是问题,这条路偃旗息鼓 我使用更多是nginx 1.11 modsec也是官网下的最新,如果你也有此次打算,建议换路子走吧。
然后开始尝试apache +modsec,网上也有不少配置
 https://www.digitalocean.com/community/tutorials/how-to-set-up-modsecurity-with-apache-on-ubuntu-14-04-and-debian-8
 这个说的比较好,其他的自己搜吧。
 然后我的bug体质又爆发了,都配置ok,但是死活不过滤危险的请求比如单引号啊,select啊之类的,在apache的vhost配置文件里面加了modsec的配置文件,提醒我已经有了,去掉,不过滤,再加再去,来来回回几个回合,某次是在无奈,一遍开日志,一遍测试,竟然过滤了,这都什么鬼。。。。。
nginx的配置文件
 (代码高亮没弄将就看吧)
 —–
 server {
listen 443 ssl;
 server_name www.aaa.xyz;
#Enable ModSecurity
 ModSecurityEnabled on;
 ModSecurityConfig modsecurity.conf;
ssl on;
 ssl_certificate /root/csr/1_www.aaa.xyz_bundle.crt;
 ssl_certificate_key /root/csr/aaa-nopass.key;
 location /{
 proxy_pass http://1.1.1.1;
 proxy_read_timeout 60;
 proxy_connect_timeout 60;
 proxy_redirect http://www.aaa.xyz https://www.aaa.xyz;
 proxy_force_ranges on;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header Host $http_host;
 proxy_set_header X-Real-IP $remote_addr;
 }
 }
 —
 几乎没有什么需要讲解的,其中1_www.aaa.xyz.bundle.crt是在前面startssl上生成的,下面的key是本机生成的,记得nopass啊,不然启动每次都需要输入密码,至于如何nopass。。。搜吧,忘了记录了
以上配置仅供参考,因为我自己都没用,碰上nginx+modsec的bug了
下来apache + modsec
—
 
 #   General setup for the virtual host
 ServerName www.aaa.xyz:443
 SSLProxyEngine on
 ProxyRequests Off
 
ProxyPass / http://1.1.1.1/
 ProxyPassReverse / http://1.1.1.1/
 SSLCertificateFile “/root/csr/1_www.aaa.xyz_bundle.crt”
 SSLCertificateKeyFile “/root/csr/aaa-nopass.key”
 
—
 感觉也基本没啥说的了
———-
ps.apache有时候需要
 a2enmod proxy_http
 a2enmod ssl
 才能启用对用的模块
发表回复