Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- See http://trac.nginx.org/nginx/ticket/97
- Given the file structure:
- /home/geira/scratch/foo
- /home/geira/scratch/bar/
- /home/geira/scratch/bar/baz
- and the nginx configuration stub:
- location /test/ {
- alias /home/geira/scratch/;
- try_files $uri bar/$uri $uri/baz =404;
- }
- let's try some experiments.
- $ HEAD http://localhost:8000/test/foo # expecting /home/geira/scratch/foo (case 1)
- 200 OK
- *10 http uri: "/test/foo"
- ...
- *10 http script var: "/test/foo"
- *10 trying to use file: "foo" "/home/geira/scratch/foo"
- *10 try file uri: "/test/foo"
- ...
- *10 http filename: "/home/geira/scratch/foo"
- ...
- *10 HTTP/1.1 200 OK
- $ HEAD http://localhost:8000/test/bar # expecting /home/geira/scratch/bar/baz (case 3)
- 200 OK
- *11 http uri: "/test/bar"
- ...
- *11 http script var: "/test/bar"
- *11 trying to use file: "bar" "/home/geira/scratch/bar"
- *11 http script copy: "bar/"
- *11 http script var: "/test/bar"
- *11 trying to use file: "bar//test/bar" "/home/geira/scratch/bar//test/bar"
- *11 http script var: "/test/bar"
- *11 http script copy: "/baz"
- *11 trying to use file: "bar/baz" "/home/geira/scratch/bar/baz"
- *11 try file uri: "/test/bar/baz"
- ...
- *11 http filename: "/home/geira/scratch/bar/baz"
- ...
- *11 HTTP/1.1 200 OK
- $ HEAD http://localhost:8000/test/baz # expecting /home/geira/scratch/bar/baz (case 2)
- 404 Not Found
- *12 http uri: "/test/baz"
- ...
- *12 http script var: "/test/baz"
- *12 trying to use file: "baz" "/home/geira/scratch/baz"
- *12 http script copy: "bar/"
- *12 http script var: "/test/baz"
- *12 trying to use file: "bar//test/baz" "/home/geira/scratch/bar//test/baz"
- *12 http script var: "/test/baz"
- *12 http script copy: "/baz"
- *12 trying to use file: "baz/baz" "/home/geira/scratch/baz/baz"
- *12 trying to use file: "=404" "/home/geira/scratch/=404"
- *12 http finalize request: 404, "/test/baz?" a:1, c:1
- *12 http special response: 404, "/test/baz?"
- ...
- *12 HTTP/1.1 404 Not Found
- -----------------------------
- Seeing concatenation with $uri doesn't work except when used as prefix,
- let's try adding a hardcoded file path to baz as fallback:
- location /test/ {
- alias /home/geira/scratch/;
- try_files $uri bar/$uri $uri/baz bar/baz =404;
- }
- $ HEAD http://localhost:8000/test/nonexistant # expecting /home/geira/scratch/bar/baz (case 4)
- 200 OK
- *13 http uri: "/test/nonexistant"
- ...
- *13 try files phase: 9
- *13 http script var: "/test/nonexistant"
- *13 trying to use file: "nonexistant" "/home/geira/scratch/nonexistant"
- *13 http script copy: "bar/"
- *13 http script var: "/test/nonexistant"
- *13 trying to use file: "bar//test/nonexistant" "/home/geira/scratch/bar//test/nonexistant"
- *13 http script var: "/test/nonexistant"
- *13 http script copy: "/baz"
- *13 trying to use file: "nonexistant/baz" "/home/geira/scratch/nonexistant/baz"
- *13 trying to use file: "bar/baz" "/home/geira/scratch/bar/baz"
- *13 try file uri: "/test/bar/baz"
- ...
- *13 HTTP/1.1 200 OK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement