我的应用程序在3000上运行,我已将代理设置为从子域名中获得3000点,但会话无法在代理上运行。
我试过这个:
app.enable('trust proxy');
但它不起作用。
Nginx配置
listen 80;
server_name sub.domain.com;
location / {
proxy_pass http://domain.com:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
会话配置
app.use(session({
store: sessionStore, //tell express to store session info in the Redis store
secret: 'mysecret',
key: 'emre',
saveUninitialized: false,
proxy: true,
resave: true,
maxAge: 60000