I have nginx 1.0.8 installed. here is my problem: I have 2 files : file1.js and file2.js. the requested path is something like this:
www.mysite.com/files_dir/%user%/file.js
If the requested header : "X-Header" exists and has the value "OK" then the responded content should be file1.js else file2.js.
The files are situated in "html/files_dir" and %user% is a set of directories that represents the usernames registered through my service.
How do I configure this in nginx? I'm not interested in php, asp or similar technologies only if it's possible with nginx.
Thanks
You could do this with nginx very easily. This is example:
You could read about HTTP variables in NGINX here , and about nginx rewrite module here
map
lets you define a variable's value based on another variable.map
should be declared athttp
level (i.e. outside ofserver
):Then the following
location
should do the trick using your new variable$file_suffix