openresty 简单安装 与限制国外IP访问

10,490次阅读
没有评论
mkdir /data/requirements
cd  /data/requirements
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
wget https://openresty.org/download/openresty-1.13.6.2.tar.gz
tar -zxvf openresty-1.13.6.2.tar.gz
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

yum -y install gcc gcc-c++ autoconf automake make

cd openresty-1.13.6.2

./configure  --with-http_sub_module --with-pcre-jit --with-ipv6 --add-module=/data/requirements/ngx_http_substitutions_filter_module

gmake 
gmake install
geoip_country /usr/share/GeoIP/GeoIP.dat;   #GeoIP所在目录
   map $geoip_country_code $allowed_country {  #变量判断
                default no;   #允许
                CN yes;  #区域不允许,这个CN就是代表中国,如果是多个地区,就是CN下面加就行
                }
if ($geoip_country_code != CN)
       {

	   return 403;
        }
yum install geoip-devel
geoiplookup /usr/share/GeoIP/GeoIP.dat 127.0.0.1
./configure  --with-http_sub_module --with-pcre-jit --with-ipv6 --add-module=/data/requirements/ngx_http_substitutions_filter_module --with-http_geoip_module --with-http_v2_module
正文完
 
yunyan
版权声明:本站原创文章,由 yunyan 2021-03-20发表,共计902字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)