Welcome! Log In Create A New Profile

Advanced

Locations with Cyrillic characters

Posted by Alex Mashin 
Locations with Cyrillic characters
October 07, 2012 04:41PM
I use nginx as a reverse proxy. I need to specify a special location(s) for certain URLs containing Cyrillic letters that would prevent caching and cache lookup, which happen otherwise (for location /).

1) Are URLs really decoded as written at http://wiki.nginx.org/HttpCoreModule#location, so that I need to type Cyrillic characters in the location directive unencoded?
2) If so, what encoding should the configuration file be in?
3) Is there a way to force a regular expression location to be matched before the location /? Or impose my own order on locations matching?
4) What is the scope of a variable set within a location?
Re: Locations with Cyrillic characters
October 08, 2012 10:14AM
Alex Mashin Wrote:
-------------------------------------------------------
> I use nginx as a reverse proxy. I need to specify a special
> location(s) for certain URLs containing Cyrillic letters that would
> prevent caching and cache lookup, which happen otherwise (for location
> /).
>
> 1) Are URLs really decoded as written at
> http://wiki.nginx.org/HttpCoreModule#location, so that I need to type
> Cyrillic characters in the location directive unencoded?
> 2) If so, what encoding should the configuration file be in?
> 3) Is there a way to force a regular expression location to be matched
> before the location /? Or impose my own order on locations matching?
> 4) What is the scope of a variable set within a location?

I can't really speak as to the text encoding (I've never used anything other than UTF8, which nginx works fine with), but as to the location, you shouldn't need need to force anything.

If it has a location that directly matches the URI it's given, it will automatically know to use it. It shouldn't matter if you spell it out (e.g. "location /forum/"), or try to use a regular expression (e.g. "location ~ ^/~(.+?)(/.*)?$" for the user directory, like apache does).

As for the variables, any variable placed within the location block will be specific to that location. If it's within the server block (but NOT in a location block), it will be global to all locations within that server block (but not accessible to other server blocks). Anything listed within the http block (but not any server blocks) will be global to all server blocks, and by extension all location blocks.

--
Piki
Re: Locations with Cyrillic characters
October 09, 2012 10:12AM
Well, this is a fragment of a configuration file for a wiki. It tries to prevent caching of pages in Служебная: (=Special:) namespace and fails, whether the configuration file is ANSI-encoded or UTF8:

# Special pages:
# Unencoded. Doesn't match for /w/index.php?title=Служебная:Random:
location /w/index.php?title=Служебная {
# do not cache...
}
# URI-encoded. Doesn't match for /w/index.php?title=Служебная:Random:
location /w/index.php?title=%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F {
# do not cache...
}

# the only location that matches for /w/index.php?title=Служебная:Random:
location / {
# cache...
}

Other locations in this configuration file, which contain only ASCII characters, match.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 165
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