首页 > 系统相关 >Nginx配置基于IP地址的访问控制

Nginx配置基于IP地址的访问控制

时间:2024-10-23 22:48:49浏览次数:3  
标签:deny 访问控制 172.16 Nginx html location allow IP地址 uhn

访问控制基于模块ngx_http_access_module实现,可以通过匹配客户端源IP地址进行限制

在location中,通过allow、deny配置仅允许172.16.0.1的主机访问 http://www.uhn.cn/admin 其他地址均拒绝

location = /admin {
root /data/nginx/html/uhn;
allow 172.16.0.1/24;
deny all;
}

location /vip {
root data/nginx/html/uhn;
index index.html;
deny 172.16.1.1;
allow 172.168.1.0/24;
allow 2001:0db8::/32;
deny all;  #按先小范围到大范围排序
}


标签:deny,访问控制,172.16,Nginx,html,location,allow,IP地址,uhn
From: https://blog.51cto.com/zywqs/12342712

相关文章

  • Nginx配置auth_basic认证,让用户访问指定页面时输入用户名密码认证
    配置方法:[root@localhost~]#yum-yinstallhttpd-toolsLoadedplugins:fastestmirrorLoadingmirrorspeedsfromcachedhostfileResolvingDependencies-->Runningtransactioncheck--->Packagehttpd-tools.x86_640:2.4.6-99.el7.centos.1willbeinstall......
  • Nginx根据返回的错误码,自定义错误页面回显
    在/data/nginx/html/uhn目录下创建一个error.html[root@localhost~]#echo"errorpage">/data/nginx/html/uhn/error.html然后修改配置文件,将 500502503504404的错误页面指向/error.html页面[root@localhost~]#cdweb[[email protected]]#viuhn.confserver......
  • 兰空图床搭建新思路:对接阿里云oss,nginx反向代理。
    我认为,图床搭建有几个关键点:提供api方便上传,且方便管理。空间够大,且稳定。不怕被盗刷流量。基于这几点,我想到了一种成本比较低的方案,即选择一台不限流量的阿里云vps+同地域的oss,上传通过兰空图床实现,访问通过nginx反向代理阿里云内网oss来实现。比如,购买阿里云99块钱的vps......
  • Nginx:各种问题
    1、nginx:commandnotfound使用ll查看文件权限,看nginx的权限是否为rw-r--r--如果是的话,说明该文件现在没有执行权限。使用指令chmod755./sbin/nginx把该文件的可执行权限开启。 2、auto/options:Nosuchfileordirectory 出现于:bash./configure配置nginx时解决方......
  • nginx上线一个静态页
    要使用Nginx配合一个静态网页,你需要按照以下步骤进行设置:###1.安装Nginx在大多数Linux发行版上,你可以使用包管理器来安装Nginx。**对于Ubuntu/Debian:**```bashsudoaptupdatesudoaptinstallnginx```**对于CentOS/RHEL:**```bashsudoyuminstallepel-releas......
  • Linux部署nginx
     linux部署启动nginx在Linux上部署并启动Nginx的步骤通常如下: 安装Nginx:使用包管理器(如apt或yum)安装Nginx。对于基于Debian的系统(如Ubuntu),使用以下命令:sudoaptupdatesudoaptinstallnginx对于基于RPM的系统(如CentOS),使用以下命令:sudoyuminsta......
  • Linux下安装Nginx,CentOS7安装Nginx
    首先,需要安装一些编译Nginx所需的依赖包,使用以下命令:yum-yinstallgccpcre-develzlib-developenssl-devel下载https://nginx.org/en/download.html上传到opt目录下或者直接在linux系统里下载wgethttp://nginx.org/download/nginx-1.26.2.tar.gz如果command......
  • redis mysql nginx的docker-compose
    redismysqlnginx的docker-composeversion:'3'services:nginx:image:docker.m.daocloud.io/nginx:latestcontainer_name:nginxrestart:unless-stoppedenvironment:TZ:Asia/ShanghaiLANG:en_US.UTF-8volumes:#......
  • k8s部署nginx
    创建namespacenginx-namespace.yamlapiVersion:v1kind:Namespacemetadata:name:ns-nginx创建Deploymentnginx-deployment.yamlapiVersion:apps/v1kind:Deploymentmetadata:name:nginx-deploymentnamespace:ns-nginxspec:selector:matchLabels:......
  • nginx配置
    为什么用postman请求本地的接口前面是http不是httpshttp://localhost:18080/api/v3/process/selectSubTableData 在开发和测试环境中,使用HTTP而不是HTTPS来请求本地接口是非常常见的做法,原因包括:简化配置:在本地开发时,通常不需要设置HTTPS,这样可以避......