Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to create a 'global' location for an NGINX server? I'd like every site served by NGINX to have access to a /global/ folder; along the lines of

http {
    [...stuff...]

    #Global path
    location /global/ {
        root /my/global/location/;
    }

    server {
        listen          127.0.0.1:80;
        server_name     example.com;

        [...standard config...]
    }

    server {
        listen          127.0.0.1:80;
        server_name     example.org;

        [...standard config...]
    }

    server {
        listen          127.0.0.1:80;
        server_name     example.net;

        [...standard config...]
    }
}

And be able to access files in the global location from http://example.com/global/ http://example.org/global/ etc.

I can do this if I add the global location block to every server block but that's annoying, I'd like to have it defined globally and be able to access it from within the sites.

I could use an include directive in each host, but it still requires specification in each host. The NGINX wiki says the 'location' block is only valid within the server context but I didn't know if there was a rewrite trick or something similar.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It's not no and as far as I know there isn't any talk of changing that either.

share|improve this answer
    
Thought so, but it was worth a try –  sam Dec 29 '11 at 14:01
4  
Well that's depressing. –  Rob Mar 1 '12 at 8:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.