首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    用Nginx禁止国外IP访问我的网站...

    图片来自 Pexels 想要实现这个功能有很多方法,下面我就来介绍基于 Nginx 的 ngx_http_geoip2 模块来禁止国外 IP 访问网站。 ①安装 geoip2 扩展依赖: [root@fxkj ~]# yum install libmaxminddb-devel -y ②下载 ngx_http_geoip2_module 模块: [root@fxkj tmp]# git clone https://github.com/leev/ngx_http_geoip2_module.git [ro tmp]# ③解压模块到指定路径 我这里解压到 /usr/local 目录下: [root@fxkj tmp]# mv ngx_http_geoip2_module/ /usr/local/ [root@fxkj local]# ll ngx_http_geoip2_module/ total 60 -rw-r--r-- 1 root root 1199 Aug 13 17:20 config -rw-r--r-- 1 root root 1311 Aug 13 17:20 LICENSE -rw-r--r-- 1 root root 23525 Aug 13 17:20 ngx_http_geoip2_module.c -rw-r--r-- 1 root root 21029 Aug 13 17:20 ngx_stream_geoip2_module.c -rw-r--r-- 1 root root 3640 Aug 13 17:20 README.md ④安装 nginx 模块 首先说明下环境,我的 nginx 版本是 1.16,在网上查了下安装 ngx_http_geoip2 模块至少需要 1.18 版本及以上,因此此次安装我是升级 nginx1.18,添加 ngx_http_geoip2 模块。 下载 nginx 1.18 版本: [root@fxkj ~]# yum install libmaxminddb-devel -y 解压 nginx1.18 软件包,并升级为 nginx1.18,添加 ngx_http_geoip2 模块。 需要注意:

    02

    生产线上的Nginx如何添加未编译安装模块

    正在生产线上跑着web前端是nginx+tomcat,现在有这样一个需求,需要对网站的单品页面和列表页设置缓存,不同的页面设置不同的缓存,但是由于开始没有安装ngx_cache_purge这个模块,现在没法直接往配置文件里边写,这时候,就需要在线安装ngx_cache_purge此模块,下边就说下怎么在线编译安装新模块。 安装步骤: 1.首先看下内核和系统的版本号。 [root@vmware1 ~]# uname -a Linux vmware1 2.6.18-308.el5 #1 SMP Tue Feb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux [root@vmware1 ~]# lsb_release -a LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch Distributor ID: CentOS Description:    CentOS release 5.8 (Final) Release:        5.8 Codename:      Final

    03
    领券