Nginx에서 관리자 패널에 대한 내 위치 제한이 작동하지 않습니다.

Nginx에서 관리자 패널에 대한 내 위치 제한이 작동하지 않습니다.

내 웹사이트는 https://www.example.com 이고 CMS 패널은 에 있습니다.

https://www.example.com/administrator-> 301 ->
https://www.example.com/administrator/-> 302
https://www.example.com/administrator/Login.aspx?Session=Out

그리고 /administrator에 대한 액세스를 제한하려고 하는데 작동하지 않습니다. 누군가 도와주실 수 있나요?

location ~*/administrator {
allow 10.0.0.0/8;
deny all;
}

여기 로그가 있습니다

192.168.5.232 - - [20/Apr/2023:09:17:57 +0530] "GET /administrator/ HTTP/2.0" 302 154 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/112.0"
192.168.5.232 - - [20/Apr/2023:09:17:57 +0530] "GET /administrator/Login.aspx?Session=Out HTTP/2.0" 200 2448 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/112.0"

오류 로그는 다음과 같습니다.

2023/04/20 09:15:34 [notice] 4810#4810: *467 "GET|HEAD|POST" matches "GET", client: 192.168.5.232, server: example.com, request: "GET /administrator/error HTTP/2.0", host: "www.example.com", referrer: "https://www.example.com/administrator/Login.aspx?Session=Out"
2023/04/20 09:17:57 [notice] 4962#4962: *513 "GET|HEAD|POST" matches "GET", client: 192.168.5.232, server: example.com, request: "GET /administrator/ HTTP/2.0", host: "www.example.com"
2023/04/20 09:17:57 [notice] 4962#4962: *513 "GET|HEAD|POST" matches "GET", client: 192.168.5.232, server: example.com, request: "GET /administrator/Login.aspx?Session=Out HTTP/2.0", host: "www.example.com"

답변1

여기에는 정규 표현식이 필요하지 않습니다. 디렉토리만 하면 됩니다

location /administrator/ {
allow 10.0.0.0/8;
deny all;
}

그리고 뒤에 공백이 누락되었는데 ~*, 이것이 아마도 실제 문제였을 것입니다.

관련 정보