nginx에서 log를 남길 때
로그 파일이름을 $hostname-access.log / error.log의 형태로 남기고 있었다.
테스트를 위해 log 경로를 수정했는데 $hostname-access.log는 하나도 남지 않고
error.log만 잔뜩 쌓여있었다.
error.log를 확인해 봤더니 아래처럼 Permission denied 에러가 발생하고 있었다.
2023/07/11 16:55:58 [crit] 68792#68792: *1 open() "/var/log/nginx/test-virtual-machine-access.log" failed (13: Permission denied) while logging request, client: {ip}, server: , request: "GET / HTTP/1.1", host: "{ip}"
2023/07/11 16:56:01 [crit] 68792#68792: *2 open() "/var/log/nginx/test-virtual-machine-access.log" failed (13: Permission denied) while logging request, client: {ip}, server: , request: "GET /robots.txt HTTP/1.1", host: "{ip}"
다음 오류가 발생할 때는 간단히 2가지 방법으로 처리할 수 있다.
1.access_log 이름을 만들 때 $hostname 삭제
2. 바뀐 log 경로에 권한확인
nginx or www-data or 사용하는 user 명 등
참고로 $hostname, $http_host, $host, $server_name은
nginx에서 사용하는 변수인데
폴더에 대한 권한이 없으면 해당 변수를 사용하지 못하는 것 같다.
'Nginx' 카테고리의 다른 글
nginx header log (custom header 사용) (0) | 2023.12.11 |
---|---|
Nginx 오류 a duplicate default server for 0.0.0.0:80 (0) | 2023.07.10 |
Nginx restrict access by ip 사용자 ip로 제한하기-2(추가작업) (0) | 2023.06.27 |
Nginx restrict access by ip 사용자 ip로 제한하기 (0) | 2023.06.26 |
Nginx resolver 설정(Dynamic DNS resolution) (0) | 2023.06.12 |