|
这里以CentOS为例,首先安装Nginx
- yum -y install wget curl python
- wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz
- tar xzf oneinstack-full.tar.gz
- cd oneinstack
- ./install.sh
复制代码 按照命令一步步操作,除了Nginx其他全部N即可。
安装Nginx之后,安装sregex
- git clone https://github.com/agentzh/sregex
- cd sregex
- make
- make install
- cd ..
复制代码 然后再编译相关模块
- cd /root/oneinstack/src
- git clone https://github.com/cuber/ngx_http_google_filter_module
- git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
- git clone https://github.com/agentzh/replace-filter-nginx-module
- wget http://mirrors.linuxeye.com/oneinstack/src/pcre-8.39.tar.gz
- wget http://mirrors.linuxeye.com/oneinstack/src/openssl-1.0.2j.tar.gz
- wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz
- tar xzf pcre-8.39.tar.gz
- tar xzf openssl-1.0.2j.tar.gz
- tar xzf v0.61.tar.gz
- tar xzf nginx-1.14.2.tar.gz
- cd nginx-1.14.2
- ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module \
- --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module \
- --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-1.0.2j \
- --with-pcre=../pcre-8.39 --with-pcre-jit --with-ld-opt='-ljemalloc' \
- --add-module=../ngx_http_google_filter_module \
- --add-module=../ngx_http_substitutions_filter_module \
- --add-module=../echo-nginx-module-0.61 \
- --add-module=../replace-filter-nginx-module
- make
复制代码 编译完成后再,执行下面几句命令
- mv /usr/local/nginx/sbin/nginx{,_`date +%m%d`}
- cp objs/nginx /usr/local/nginx/sbin/
- ln -s /usr/local/lib/libsregex.so.0 /lib64
复制代码 最后重启Nginx,如果不报错,那就可以使用了
配置举例(用baidu.8dou.com反代百度):
- server {
- listen 80;
- server_name baidu.8dou.com;
- resolver 8.8.8.8;
- location / {
- proxy_pass https://www.baidu.com;
- }
- }
复制代码 |
|