參考資料
從請求中獲取值
-- 從請求中獲取請求頭爲 Sec-WebSocket-Protocol 的值
secWebSocketProtocol=ngx.req.get_headers()["Sec-WebSocket-Protocol"]
-- 從 cookie 中獲取uid對應的值
uid=ngx.var.cookie_uid
-- 獲取我們在 nginx 中定義的變量
-- set $lct "initialD";
location=ngx.var.lct
-- 從請求頭中獲取來源 ip
ip=headers["X-REAL-IP"] or headers["X_FORWARDED_FOR"] or ngx.var.remote_addr