【发布时间】:2017-07-31 22:12:57
【问题描述】:
我有一个 nginx 服务器,用作转发代理。我想为架构添加一层身份验证,我正在使用 Lua。
我正在使用https://github.com/bungle/lua-resty-session 模块在 lua 中启用会话。
local session = require "resty.session".open{ cookie = { domain = cookie_domain } }
-- Read some data
if session.present then
ngx.log(ngx.ERR, "Session -- "..session.id)
end
if not session.started then
session:start()
ngx.log(ngx.ERR, "Started -- ")
end
在服务器收到每个请求后,我都会收到日志消息
开始 --
服务器配置:
server {
listen 80;
server_name {SERVER_IP};
# tons of pagespeed configuration
location / {
#basic authentication
##auth_basic "Restricted";
##auth_basic_user_file {PATH_FOR_HTPASS_FILE};
access_by_lua_file {PATH_FOR_LUA_FILE};
# cache name
proxy_cache browser_cache;
resolver 8.8.8.8;
# app1 reverse proxy follow
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://$http_host$uri$is_args$args;
}
}
我看到的唯一问题是 cookie_domain,服务器没有指向域,我将服务器的 IP 地址 作为 cookie_domain 传递。我无法找出问题的原因。
【问题讨论】:
标签: session nginx proxy lua openresty