V
V
v2t2014-01-02 17:04:59
Nginx
v2t, 2014-01-02 17:04:59

How to disable logging in nginx if the url contains a certain sequence of characters?

Good afternoon!
Help me to correctly compose the location to exclude entries from the error log if the url contains the @5h sequence.
The essence of the problem is that the site.com/a/b/*@5h*.png file, which does not exist on the server, is periodically requested. At the same time, an entry about this gets into error.log. It is necessary to correctly compose the location in order to disable logging.
Tried:

location ~* \@5h {
    log_not_found off;
}

Also
location ~* @5h {
location ~ @5h {
location ~ @5h* {
location ~* @5h* {

None of the options worked. When requesting site.com/a/b/[email protected] , the entry gets into the log.
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
evnuh, 2014-01-02
@evnuh

Does nginx's location check order exactly arrive at the correct location?
Also check if there are any prefix locations like this:

If the longest matching prefix location has the “^~” modifier then regular expressions are not checked.

E
Eugene, 2014-01-02
@Nc_Soft

Put deny all in the location to make sure it gets there. It seems to me that no.
Maybe @ should be urlencoded

V
v2t, 2014-01-03
@v2t

@evnuh , @Nc_Soft , thanks for helping me solve the problem! Indeed, in front of the location I needed was one that did not allow me to reach the desired one.
After placement

location ~* \@5h {
    log_not_found off;
}

to the right place, entries in the log ceased to fall.
However, there are doubts about the correctness of the compilation of the location record itself.
Tell me, which of the location expressions is best to implement such a task?
Thank you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question