selinux对linux服务的影响

实验一:使用 web 服务演示安全上下文值的设定
[root@localhost ~] # systemctl restart nginx
通过客户端测试,出现 403 状态码
# 修改自定义目录的安全上下文的值:
[root@localhost ~] # chcon -t httpd_sys_content_t /www/ -R
也可以将自定义目录的安全上下文的值按照 /var/www/html 文件修改:
[root@localhost ~] # chcon -R --reference=/usr/share/nginx/html/index.html
/www
修改之后即可成功访问。
实验二:使用 web 服务端口的改变来演示端口的设定
[root@localhost ~] # vim /etc/httpd/conf.d/host.conf
[root@master-dns ~] # cat /etc/nginx/conf.d/test_port.conf
server {
listen 192 .168.168.153:80;
root /www/port/80;
location / {}
}
server {
listen 192 .168.168.153:10000;
root /www/port/10000;
location / {}
}
[root@localhost ~] # mkdir -pv /www/port/{80,10000}
[root@localhost ~] # echo the port is 80 > /www/port/80/index.html
[root@localhost ~] # echo the port is 10000 > /www/port/10000/index.html
[root@master-dns ~] # systemctl restart nginx
# 服务重启失败,查看日志
[root@localhost ~] # tail -f /var/log/messages
# 添加 10000 端口为服务端口:
[root@localhost ~] # semanage port -a -t http_port_t -p tcp 10000
[root@master-dns ~] # systemctl restart nginx
[root@master-dns ~] # curl 192.168.168.153:10000
the port is 10000
# 测试可以访问成功
  • 9
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值