daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Apr 16th, 2015 236 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. See http://trac.nginx.org/nginx/ticket/97
  2.  
  3. Given the file structure:
  4.  
  5.   /home/geira/scratch/foo
  6.   /home/geira/scratch/bar/
  7.   /home/geira/scratch/bar/baz
  8.  
  9. and the nginx configuration stub:
  10.  
  11.   location /test/ {
  12.       alias /home/geira/scratch/;
  13.       try_files $uri bar/$uri $uri/baz =404;
  14.   }
  15.  
  16. let's try some experiments.
  17.  
  18. $ HEAD http://localhost:8000/test/foo  # expecting /home/geira/scratch/foo (case 1)
  19. 200 OK
  20.  
  21.  *10 http uri: "/test/foo"
  22. ...
  23.  *10 http script var: "/test/foo"
  24.  *10 trying to use file: "foo" "/home/geira/scratch/foo"
  25.  *10 try file uri: "/test/foo"
  26. ...
  27.  *10 http filename: "/home/geira/scratch/foo"
  28. ...
  29.  *10 HTTP/1.1 200 OK
  30.  
  31. $ HEAD http://localhost:8000/test/bar  # expecting /home/geira/scratch/bar/baz (case 3)
  32. 200 OK
  33.  
  34.  *11 http uri: "/test/bar"
  35. ...
  36.  *11 http script var: "/test/bar"
  37.  *11 trying to use file: "bar" "/home/geira/scratch/bar"
  38.  *11 http script copy: "bar/"
  39.  *11 http script var: "/test/bar"
  40.  *11 trying to use file: "bar//test/bar" "/home/geira/scratch/bar//test/bar"
  41.  *11 http script var: "/test/bar"
  42.  *11 http script copy: "/baz"
  43.  *11 trying to use file: "bar/baz" "/home/geira/scratch/bar/baz"
  44.  *11 try file uri: "/test/bar/baz"
  45. ...
  46.  *11 http filename: "/home/geira/scratch/bar/baz"
  47. ...
  48.  *11 HTTP/1.1 200 OK
  49.  
  50. $ HEAD http://localhost:8000/test/baz  # expecting /home/geira/scratch/bar/baz (case 2)
  51. 404 Not Found
  52.  
  53.  *12 http uri: "/test/baz"
  54. ...
  55.  *12 http script var: "/test/baz"
  56.  *12 trying to use file: "baz" "/home/geira/scratch/baz"
  57.  *12 http script copy: "bar/"
  58.  *12 http script var: "/test/baz"
  59.  *12 trying to use file: "bar//test/baz" "/home/geira/scratch/bar//test/baz"
  60.  *12 http script var: "/test/baz"
  61.  *12 http script copy: "/baz"
  62.  *12 trying to use file: "baz/baz" "/home/geira/scratch/baz/baz"
  63.  *12 trying to use file: "=404" "/home/geira/scratch/=404"
  64.  *12 http finalize request: 404, "/test/baz?" a:1, c:1
  65.  *12 http special response: 404, "/test/baz?"
  66. ...
  67.  *12 HTTP/1.1 404 Not Found
  68.  
  69. -----------------------------
  70.  
  71. Seeing concatenation with $uri doesn't work except when used as prefix,
  72. let's try adding a hardcoded file path to baz as fallback:
  73.  
  74. location /test/ {
  75.     alias /home/geira/scratch/;
  76.     try_files $uri bar/$uri $uri/baz bar/baz =404;
  77. }
  78.  
  79. $ HEAD http://localhost:8000/test/nonexistant  # expecting /home/geira/scratch/bar/baz (case 4)
  80. 200 OK
  81.  
  82.  *13 http uri: "/test/nonexistant"
  83. ...
  84.  *13 try files phase: 9
  85.  *13 http script var: "/test/nonexistant"
  86.  *13 trying to use file: "nonexistant" "/home/geira/scratch/nonexistant"
  87.  *13 http script copy: "bar/"
  88.  *13 http script var: "/test/nonexistant"
  89.  *13 trying to use file: "bar//test/nonexistant" "/home/geira/scratch/bar//test/nonexistant"
  90.  *13 http script var: "/test/nonexistant"
  91.  *13 http script copy: "/baz"
  92.  *13 trying to use file: "nonexistant/baz" "/home/geira/scratch/nonexistant/baz"
  93.  *13 trying to use file: "bar/baz" "/home/geira/scratch/bar/baz"
  94.  *13 try file uri: "/test/bar/baz"
  95. ...
  96.  *13 HTTP/1.1 200 OK
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand