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 # 测试可以访问成功 ![](https://i-blog.csdnimg.cn/direct/60a4fb17be52485aa62dbab09395cc64.png)

相关推荐
jerryinwuhan2 分钟前
网络安全相关制度
网络·安全·web安全
c++逐梦人4 分钟前
Linux生产者消费者模型
linux
2401_865439635 分钟前
CSS如何实现图片自动裁剪填充_巧用object-fit属性控制尺寸
jvm·数据库·python
竹之却8 分钟前
【Agent-阿程】OpenClaw 版本更新v2026.4.14
网络·安全·openclaw
m0_748839499 分钟前
HTML函数能否用液态金属散热提升性能_极端散热方案实测【汇总】
jvm·数据库·python
2301_8035389510 分钟前
mysql添加索引导致插入变慢怎么办_索引优化与异步处理方案
jvm·数据库·python
2301_7826591811 分钟前
如何防止SQL脏数据写入_利用触发器实现强一致性校验
jvm·数据库·python
2301_8176722614 分钟前
如何实现元素从底部进入视口时触发 sticky 定位
jvm·数据库·python
InfinteJustice20 分钟前
mysql如何排查插件加载失败原因_mysql plugin目录与权限核对
jvm·数据库·python
洛水水21 分钟前
KVStore 内存池实战:从实现到应用,告别 malloc 焦虑
网络·内存池