【发布时间】:2020-06-07 01:49:49
【问题描述】:
我在 Centos 7 上使用 NGINX。 我阻止了所有 PHP 请求,因为我的 Web 服务器只有静态 html 文件。 我的 NGINX 配置如下;
server {
listen myIp:80;
server_name myDomain;
location ~(\.php$) {
return 403;
}
return 301 https://myDomain$request_uri;
}
但它返回 301 请求 index.php。我的 access.log 如下所示;
43.226.148.141 - - [23/Feb/2020:04:36:54 +0900] "GET /mysql/admin/index.php HTTP/1.1" 301 162 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-"
我预计 NGINX 将返回 404,因为 index.php 不存在或返回 403,因为我添加了限制,但在 access.log 中它返回 301。 当我通过在网络浏览器上输入“myDomain/mysql/admin/index.php”来尝试它时,我在 301 之后得到 403。
谁能解释一下我的 NGINX 服务器上发生了什么并帮我解决这个问题?
【问题讨论】:
标签: nginx configuration centos