新网虚拟主机403被拦截_chmod与index配置
403被拦截时分清是服务器 403 还是 CDN/WAF 403。服务器 403 页面有 Nginx/Apache 标识,CDN 403 页面有 CDN 标识。CDN 403 通常是 WAF 规则拦截或防盗链,服务器 403 是权限或配置问题。用 curl -x 127.0.0.1:80 测源站,区分层级。
默认首页排查:Nginx 的 index 指令(index index.html index.htm index.php;),Apache 的 DirectoryIndex,IIS 的默认文档。目录下没有这些文件且目录浏览关闭就返回 403。上传 index 文件或在配置里加默认首页。虚拟主机在面板的"默认文档"里设置。
参考(403权限修复命令): ``` # 查看权限和属主 ls -la /www/wwwroot/域名 ls -la /www/wwwroot/域名/index.php
# 批量修复权限 find /www/wwwroot/域名 -type d -exec chmod 755 {} ; find /www/wwwroot/域名 -type f -exec chmod 644 {} ;
# 修复属主(Nginx) chown -R www:www /www/wwwroot/域名 # Apache chown -R apache:apache /www/wwwroot/域名 # 写入目录给775 chmod 775 /www/wwwroot/域名/upload chown www:www /www/wwwroot/域名/upload
# Nginx错误日志 tail -50 /var/log/nginx/error.log # Apache错误日志 tail -50 /var/log/httpd/error_log
# 测试源站(绕过CDN) curl -I -x 127.0.0.1:80 http://域名/ ```
排查完用 netstat 端口检测确认。修复后 curl -I http://域名/页面返回 200,浏览器无痕模式访问正常,图片和静态资源都能加载。如果是权限问题,确认所有目录和文件权限正确,不要留 777。如果是规则问题,确认规则只拦截目标不影响正常访问。
Apache 403 专项:Apache 错误日志在 /var/log/httpd/error_log 或 /var/log/apache2/error.log,常见 "client denied by server configuration"(deny 规则或 Options)、"Permission denied"(文件系统权限)。.htaccess 语法错误会导致 500 不是 403,注意区分。

更新时间:2026-08-27 12:07:01