Red Hat Enterprise Linux Server release 6.3 (Santiago)
wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz
wget http://nginx.org/download/nginx-1.6.0.tar.gz
yum install -y prce
tar -xzvf ngx_cache_purge-2.1.tar.gz -C /usr/local
tar -xzvf nginx-1.6.0.tar.gz
cd nginx-1.6.0
./configure --prefix=/usr/local/nginx --user=www --group=www --add-module=/usr/local/ngx_cache_purge-2.1 --with-http_sub_module --with-http_stub_status_module --with-http_ssl_module
make
make install
建立ssl 加密认证密钥
yum install openssl*
cd /usr/local/nginx/conf
openssl genrsa -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
在nginx.conf添加一下配置
########################################################################################
http{
proxy_cache_path /home/www/cache/one levels=1:2 keys_zone=one:10m max_size=10g;
proxy_cache_key "$host$request_uri";
server {
listen 80;
server_name www.abc.com abc.com;
rewrite ^(.*) https://www.abc.com$1 permanent;
}
upstream google {
server 74.125.224.80:80 max_fails=3;
server 74.125.224.81:80 max_fails=3;
server 74.125.224.82:80 max_fails=3;
server 74.125.224.83:80 max_fails=3;
server 74.125.224.84:80 max_fails=3;
}
server {
listen 443;
server_name www.abc.com abc.com;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
location / {
proxy_cache one;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 404 1m;
proxy_redirect https://www.google.com.hk/ /;
proxy_cookie_domain google.com abc.com;
proxy_pass http://google;
proxy_set_header Host "www.google.com.hk";
proxy_set_header Accept-Encoding "";
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Language "zh-CN";
proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2w1IQ-Maw";
sub_filter www.google.com.hk www.abc.com;
sub_filter_once off;
#为了防止被国家防火墙,最好最个访问限制
allow 180.168.181.a/32;
allow 124.17.b.0/24;
deny all;
}
}
}
##########################################################################
/usr/local/nginx/sbin/nginx ##启动nginx