Welcome! Log In Create A New Profile

Advanced

access log if in location on windows nginx not work

Posted by baiclamp 
access log if in location on windows nginx not work
February 05, 2021 07:40AM
Hi,I config condition access log below:

http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;


log_format mylogview escape=json '[view]\n\n'
'QueryString:$query_string\n\n'
'Time=$time_iso8601\n\n'
'URL=$scheme//$hostname$request_uri\n\n'
'Referer=$http_referer\n\n'
'User-Agent=$http_user_agent\n\n'
'IP=$remote_addr\n\n';




sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
server_name localhost;
rewrite_log on;
#charset koi8-r;

#access_log logs/host.access.log main;





location /b/ {


# access_log logs/picview.txt mylogview;
# this above work
if ($uri ~* '\.(gif|jpg|jpeg|png|bmp)$') {



access_log logs/view.txt mylogview;
# not work but match

}

if ($query_string ~ '.+') {

access_log logs/picview.txt mylogdownload;
#match not work
}


if ($http_user_agent ~ 'Windows NT (6|10)\.[0-4]+;') {
rewrite ^/b/(.*)\.chm$ /d/$1.docx break;
}

if ($http_user_agent ~ '(iPhone|iPad)') {
rewrite ^/b/(.*)\.chm$ /e/$1.doc break;
}

}


............................

when the access log put in location is worked

but put inside the location - if () { } it did not work. but work in linux

And I don't know why.

-----------------------------------
below is debug log

2021/02/05 19:39:40 [notice] 1280#3260: *5 "\.(gif|jpg|jpeg|png|bmp)$" matches "/b/a.jpg", client: 172.18.18.153, server: localhost, request: "GET /b/a.jpg?a=b HTTP/1.1", host: "172.18.18.153"
2021/02/05 19:39:40 [notice] 1280#3260: *5 ".+" matches "a=b", client: 172.18.18.153, server: localhost, request: "GET /b/a.jpg?a=b HTTP/1.1", host: "172.18.18.153"
2021/02/05 19:39:40 [notice] 1280#3260: *5 "Windows NT (6|10)\.[0-4]+;" matches "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko", client: 172.18.18.153, server: localhost, request: "GET /b/a.jpg?a=b HTTP/1.1", host: "172.18.18.153"
2021/02/05 19:39:40 [notice] 1280#3260: *5 "^/b/(.*)\.chm$" does not match "/b/a.jpg", client: 172.18.18.153, server: localhost, request: "GET /b/a.jpg?a=b HTTP/1.1", host: "172.18.18.153"
2021/02/05 19:39:40 [notice] 1280#3260: *5 "(iPhone|iPad)" does not match "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko", client: 172.18.18.153, server: localhost, request: "GET /b/a.jpg?a=b HTTP/1.1", host: "172.18.18.153"
2021/02/05 19:39:40 [error] 1280#3260: *5 CreateFile() "C:\www\nginx-1.16.1/html/b/a.jpg" failed (3: The system cannot find the path specified), client: 172.18.18.153, server: localhost, request: "GET /b/a.jpg?a=b HTTP/1.1", host: "172.18.18.153"
2021/02/05 19:46:04 [debug] 3028#5220: bind() 0.0.0.0:80 #556

so I seens matches. but not log. and what ever where I put the access_log. the debug message no include any info about access log. but it could logged when put in the location .

could someone know what 's wrong?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 249
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready