web服务目录的访问权限的控制

简介:

1.确认web服务器已经安装并启动

[root@www ~]# ls /usr/local/httpd/

bin  build  cgi-bin  conf  error  htdocs  icons  include  lib  logs  man  manual  modules

[root@www ~]# netstat -utpln |grep 80

tcp        0      0 :::80                       :::*                        LISTEN      73341/httpd   

2.设置只允许192.168.100.110访问,其他主机拒绝:

[root@www ~]# vim /usr/local/httpd/conf/httpd.conf

1
2
3
4
5
6
7
8
421 <Directory  "/usr/local/awstats/wwwroot" >
422     Options None
423     AllowOverride None
424     Order allow,deny
425     Allow from 192.168.100.1    ##修改该行
426 < /Directory >
427 
: set  nu   ##打印行号

:wq

[root@www ~]# /etc/init.d/httpd restart   ##重启服务

httpd is restart complete.

测试:

修改windows主机的VNET1的IP为192.168.100.10,访问测试:

http://www.linuxyy.cn/aws.html    ##不能访问

http://www.linuxyy.cn    ##能访问

修改windows主机的VNET1的IP为192.168.100.1,访问测试:

http://www.linuxyy.cn/aws.html    ##能访问

http://www.linuxyy.cn    ##能访问


3.用户授权限制:

1)创建认证用户的密码文件(password file):

[root@www ~]# /usr/local/httpd/bin/htpasswd -c /usr/local/httpd/conf/htpasswd admin  ##添加admin用户

New password:   ##输入密码pwd@123

Re-type new password:    ##确认密码

Adding password for user admin  

[root@www ~]# cat /usr/local/httpd/conf/htpasswd   

admin:TpPLVJuXl0wsE

/usr/local/httpd/bin/htpasswd /usr/local/httpd/conf/htpasswd jhon

/usr/local/httpd/bin/htpasswd -c /usr/local/httpd/conf/htpasswd yy

相同的方法分别添加jhon,yy两个用户。

[root@www ~]# vim /usr/local/httpd/conf/htgroups   ##为授权用户加入组

1
mygroup: admin yy    ##组名: 成员1  成员2


2)添加用户授权配置

[root@www ~]# vim /usr/local/httpd/conf/httpd.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
421 <Directory  "/usr/local/awstats/wwwroot" >
422     Options None
423     AllowOverride None
424     Order allow,deny
425     Allow from 192.168.100.110
426     AuthType Basic      ##定义认证的类型为Basic
427     AuthName  "Log analysis system"     ##提示短语
428     AuthBasicProvider  file    ##提供认证者为file
429     AuthUserFile  /usr/local/httpd/conf/htpasswd    ##指定认证用户文件
430     AuthGroupFile  /usr/local/httpd/conf/htgroups    ##指定认证组文件
431     Require group mygroup    ##设置允许访问的用户或者组,如果设置为用户改为“Require valid-user”即可
432 < /Directory >
433

:set nu    

:wq

[root@www ~]# /etc/init.d/httpd restart   ##重启服务

httpd is restart complete.

3)访问测试:

http://www.linuxyy.cn/aws.html  ##输入用户测试,admin与yy能登录,jhon不能登录

注意验证不同用户时只需关闭重新打开即可














本文转自信自己belive51CTO博客,原文链接:http://blog.51cto.com/11638205/1981661 ,如需转载请自行联系原作者
相关文章
|
5月前
|
XML JSON 数据安全/隐私保护
Web服务
【10月更文挑战第18天】Web服务
86 9
|
1月前
|
数据采集 Web App开发 API
FastAPI与Selenium:打造高效的Web数据抓取服务 —— 采集Pixabay中的图片及相关信息
本文介绍了如何使用FastAPI和Selenium搭建RESTful接口,访问免版权图片网站Pixabay并采集图片及其描述信息。通过配置代理IP、User-Agent和Cookie,提高爬虫的稳定性和防封禁能力。环境依赖包括FastAPI、Uvicorn和Selenium等库。代码示例展示了完整的实现过程,涵盖代理设置、浏览器模拟及数据提取,并提供了详细的中文注释。适用于需要高效、稳定的Web数据抓取服务的开发者。
107 15
FastAPI与Selenium:打造高效的Web数据抓取服务 —— 采集Pixabay中的图片及相关信息
|
1月前
|
网络协议 Java Shell
java spring 项目若依框架启动失败,启动不了服务提示端口8080占用escription: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port-优雅草卓伊凡解决方案
java spring 项目若依框架启动失败,启动不了服务提示端口8080占用escription: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port-优雅草卓伊凡解决方案
73 7
|
2月前
|
Web App开发 编解码 vr&ar
使用Web浏览器访问UE应用的最佳实践
在3D/XR应用开发中,尤其是基于UE(虚幻引擎)开发的高精度场景,传统终端因硬件局限难以流畅运行高帧率、复杂效果的三维应用。实时云渲染技术,将渲染任务转移至云端服务器,降低终端硬件要求,确保用户获得流畅体验。具备弹性扩展、优化传输协议、跨平台支持和安全性等优势,适用于多种终端和场景,特别集成像素流送技术,帮助UE开发者实现低代码上云操作,简化部署流程,保留UE引擎的强大开发能力,确保画面精美且终端轻量化。
128 17
使用Web浏览器访问UE应用的最佳实践
|
5月前
|
XML JSON 安全
Web服务是通过标准化的通信协议和数据格式
【10月更文挑战第18天】Web服务是通过标准化的通信协议和数据格式
217 69
|
4月前
|
Go UED
Go Web服务中如何优雅平滑重启?
在生产环境中,服务升级时如何确保不中断当前请求并应用新代码是一个挑战。本文介绍了如何使用 Go 语言的 `endless` 包实现服务的优雅重启,确保在不停止服务的情况下完成无缝升级。通过示例代码和测试步骤,详细展示了 `endless` 包的工作原理和实际应用。
97 3
|
4月前
|
JSON Go UED
Go Web服务中如何优雅关机?
在构建 Web 服务时,优雅关机是一个关键的技术点,它确保服务关闭时所有正在处理的请求都能顺利完成。本文通过一个简单的 Go 语言示例,展示了如何使用 Gin 框架实现优雅关机。通过捕获系统信号和使用 `http.Server` 的 `Shutdown` 方法,我们可以在服务关闭前等待所有请求处理完毕,从而提升用户体验,避免数据丢失或不一致。
55 1
|
4月前
|
XML 安全 PHP
PHP与SOAP Web服务开发:基础与进阶教程
本文介绍了PHP与SOAP Web服务的基础和进阶知识,涵盖SOAP的基本概念、PHP中的SoapServer和SoapClient类的使用方法,以及服务端和客户端的开发示例。此外,还探讨了安全性、性能优化等高级主题,帮助开发者掌握更高效的Web服务开发技巧。
|
5月前
|
XML JSON 安全
定义Web服务
【10月更文挑战第18天】定义Web服务
113 12
|
4月前
【Azure App Service】PowerShell脚本批量添加IP地址到Web App允许访问IP列表中
Web App取消公网访问后,只允许特定IP能访问Web App。需要写一下段PowerShell脚本,批量添加IP到Web App的允许访问IP列表里!

热门文章

最新文章