F
F
FilimoniC2011-06-09 23:47:28
Nginx
FilimoniC, 2011-06-09 23:47:28

nginx regexp question

Please help.
Problem:
When requesting the file http: //serv/*.pgp, the contents of key.pgp were returned,
but not when requesting http: //serv/something/*.pgp
(instead of * - any set of [a-zA-Z0-9\ .] (alphanumeric and period)

location ~* /[a-zA-Z0-9\.]+\.(pgp|gpg|key)$ {

root /www/http/_global;
rewrite $ /key.pgp break;
}

location = /key.pgp {
root /www/http/_global;
}

second condition doesn't work (request http: //serv/something/key.php returns a file)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VBart, 2011-06-10
@FilimoniC

First, /[a-zA-Z0-9\.]+\.(pgp|gpg|key)$ will match any URI ending in /*.pgp (including /something/*.pgp), you they themselves did not bind the regular season to the beginning of the "^".
Secondly, do you really need a rewrite right now?

location ~* ^/[a-z0-9\.]+\.(pgp|gpg|key)$ {
    try_files /www/http/_global/key.pgp =404;
}

S
sergeyvolobuev, 2011-06-10
@sergeyvolobuev

here the priorities of locations are well described.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question