Skip to content

Instantly share code, notes, and snippets.

@frozenminds
Created September 7, 2016 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frozenminds/cdc87c5b1e3f3d46ae2b72a5678498e7 to your computer and use it in GitHub Desktop.
Save frozenminds/cdc87c5b1e3f3d46ae2b72a5678498e7 to your computer and use it in GitHub Desktop.
Nginx shared vars
server {
listen 80;
server_name test.dev;
root /var/www/html;
userid on;
default_type text/html;
index index.html;
charset utf-8;
set $unique $uid_got$uid_set;
location / {
ssi on;
access_by_lua_block {
ngx.log(ngx.ERR, "[ROUTE /] UNIQUE: " .. (ngx.var.unique or "unavailable"))
ngx.log(ngx.ERR, "[ROUTE /] UID_GOT: " .. (ngx.var.uid_got or "unavailable"))
ngx.log(ngx.ERR, "[ROUTE /] UID_SET: " .. (ngx.var.uid_set or "unavailable"))
}
try_files $uri $uri/ @handler;
}
location @handler {
ssi on;
access_by_lua_block {
ngx.log(ngx.ERR, "[ROUTE @handler] UNIQUE: " .. (ngx.var.unique or "unavailable"))
ngx.log(ngx.ERR, "[ROUTE @handler] UID_GOT: " .. (ngx.var.uid_got or "unavailable"))
ngx.log(ngx.ERR, "[ROUTE @handler] UID_SET: " .. (ngx.var.uid_set or "unavailable"))
}
# might be srcache_fetch/fastcgi_pass/etc.
content_by_lua_block {
local html = [[
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Main Request</title>
</head>
<body>
<h1>Main Request</h1>
<p>UID_GOT: <!--#echo var="uid_got" default="ssi uid_got unavailable" --></p>
<p>UID_SET: <!--#echo var="uid_set" default="ssi uid_set unavailable" --></p>
<p>UNIQUE: <!--#echo var="unique" default="ssi unique unavailable" --></p>
</body>
</html>
]]
ngx.print(html)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment