您的位置:首页 > 运维架构 > 反向代理

利用Nginx 做反向代理替换掉页面部分内容

2015-09-12 00:00 681 查看
摘要: nginx 反向代理 替换模块安装配置

cd /usr/local/src
wget -c http://nginx.org/download/nginx-1.9.4.tar.gz wget -c https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/master.zip unzip master.zip
tar -xzf nginx-1.9.4.tar.gz
yum -y install pcre-devel openssl openssl-devel

cd nginx-1.9.4
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-http_realip_module --add-module=/usr/local/src/ngx_http_substitutions_filter_module-master
make && make install

server
{
listen          80;
server_name    www.yourdomain.com;
location / {
proxy_pass             http://www.target_host.cn; proxy_redirect          off;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
subs_filter search_text    replace_text;
index   index.html index.htm;
}
}

修改配置文件后,加载新的配置使生效

/usr/local/nginx/sbin/nginx -s reload
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: