Add secure flag to JSESSIONID cookie in spring automatically

后端 未结 5 811
广开言路
广开言路 2020-12-11 02:08

I have a tomcat application server that is behind a nginx. SSL terminates on the nginx. The Spring web-mvc application that is deployed on the tomcat should set the secure f

5条回答
  •  借酒劲吻你
    2020-12-11 02:52

    Behind nginx as ssl terminal point it is not trivial task: secured connection must be detected by nginx header (X-Forwarded-Proto: https, see Using the Forwarded header)
    But it is easy solved by nginx config:

    if ($scheme = http) {
        return 301 https://$http_host$request_uri;
    }
    proxy_cookie_path / "/; secure";
    

提交回复
热议问题