2016-09-03 10 views
0

私はredis接続とnginxプロキシを使用してexpress-sessionモジュールを使用しています。 secure:falseと一緒に使用すると、sidクッキーが設定されます。しかし、私がそれを確保するために設定した場合、それはしません。私は明示的かつ安全に他のクッキーを直接設定しています:真実であり、動作します。nodejsモジュールを使用するsecure with secureが動作しない

エクスプレスエクスプレス・セッションの設定:

//proxy configuration 
app.set('trust proxy', 1); // trust first proxy (ngnix proxy) 

//session 

app.use(session({ 
    secret: 'to-secret-to-show', 
    resave: false, 
    saveUninitialized: true, 
    rolling: true, 
    cookie: { 
     httpOnly: true, 
     sameSite: 'strict', 
     secure: secure 
    }, 
    store: new RedisSessionStore({ 
     client: redis, 
     ttl: 86400, //time to life, one day 
    }), 
})); 

のセキュアはenvirementに真または偽depentsに設定されている場合。私はそれを真に直接設定しようとしますが、チャネージを作成しません。

nginxのプロキシ設定:

proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Host $http_host; 
     proxy_set_header X-NginX-Proxy true; 
     #proxy_set_header X-Forwarded-Host $http_host; 

     proxy_pass http://nodejs; 
     proxy_redirect off; 

私はそれが正しいはずDokumentationファイルを見てみると。私は何かを忘れましたか?私は重いテストをすることはできません。なぜなら、私のライブシステムは安全な接続しか持たないからです。 X-Forwarded-Protoヘッダを付加

答えて

1

試行:

proxy_set_header X-Forwarded-Proto $scheme; 

これはnginxのへの接続がセキュアである場合express-sessionを決定する方法です。

関連する問題