使用docker-compose部署nginx报错403 Forbidden nginx/1.25.4

使用docker-compose部署nginx以后使用在网页访问403错误

我的docker-compose内容如下:

[root@localhost compose-nginx]# cat docker-compose.yaml 
version: "2.16.0"  
services:  
  nginx:  
    hostname: nginx  
    build:  
      context: ./nginx  
      dockerfile: Dockerfile  
    ports:  
      - "1216:80"  
      - "1217:443"  
    networks:  
      - cluster  
    volumes:  
      - ./wwwroot/:/usr/local/nginx/html  
      

networks:  
  cluster:

假设在docker-compose.yaml文件中定义了一个名为nginx的服务且服务正在运行,可以用以下命令进入该容器:

docker-compose exec nginx bash

查找报错日志

find / -name error.log

报错如下

[root@nginx var]# cat /usr/local/nginx/logs/error.log

2024/04/02 04:18:54 [error] 8#0: *1 directory index of "/usr/local/nginx/html/" is forbidden, client: 192.168.25.1, server: localhost, request: "GET / HTTP/1.1", host: "192.168.25.131:1216" 2024/04/02 04:18:55 [error] 8#0: *1 directory index of "/usr/local/nginx/html/" is forbidden, client: 192.168.25.1, server: localhost, request: "GET / HTTP/1.1", host: "192.168.25.131:1216"

这条日志信息显示的是 Nginx 在尝试提供目录列表时遇到的问题。错误消息指出,Nginx 禁止了 /usr/local/nginx/html/ 目录的索引(即不允许列出目录内容)。这通常是因为 Nginx 的配置中没有启用目录列表功能,或者该目录中没有默认的索引文件(如 index.html 或 index.php

使用find查找index.html文件复制到 /usr/local/nginx/html/

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值