Multiple URL parameters in the same location directive.

Quintin Par quintinpar at
Sun Oct 28 03:59:35 UTC 2012

Hi all,

I have some URL patterns that follow the same directive specifications.

E.g. sitemap.xml, robots.txt etc. follow the same location directive with
the same caching policy, invalidation etc.

        location /robots.txt {

            proxy_pass  http://localhost:82;

            proxy_set_header   Host             $host;

            proxy_set_header   X-Real-IP        $remote_addr;

            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

            proxy_set_header Accept-Encoding "";

            proxy_ignore_headers Cache-Control;

            proxy_ignore_headers Expires;

            proxy_ignore_headers X-Accel-Expires;

            proxy_cache             cache;

            proxy_cache_key         $scheme$host$request_uri;

            proxy_cache_valid       200 302 2m;

            proxy_cache_use_stale   updating;


Now I have written separate directives for all of these URL patterns.

How can I combine them into one line?

Can I do this?

        location /robots.txt, sitemap.xml, ~*.xml {

etc. ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list