限制IP与Laravel在NGINX上的访问



拒绝使用Laravel有效的nginx上的路径访问,但访问的页面断开允许的IP地址。我究竟做错了什么?

我一直在使用以下片段来阻止访问http://some.url/admin(and http://some.url/admin/login)。用于其他目的,例如WordPress。

# Restrict administrative access
location /admin/ {
  allow x.x.x.x;
  deny all;
}

从非允许的IP访问时,我会遇到403错误,这很好。👍
但是从允许的IP访问时,我会遇到404错误。👎

2017/02/20 18:40:36 [error] 2663#2663: *325 "/var/www/some-website/html/public/admin/index.php" is not found (2: No such file or directory), client: x.x.x.x, server: some.website, request: "GET /admin/ HTTP/2.0", host: "some.website"

我怀疑我的Laravel应用程序中的路线出现问题。

很多反复试验,在网上搜索和Stackoverflow搜索没有成功的答案。预先感谢!

ps。这是我的第一篇文章。如果我做错了什么,请告诉我。

这是可能的。通过将其添加到位置块中,将位置指向根部:

try_files $uri $uri/ /index.php?$query_string;

最新更新