Reputation: 31
On the nginx i need to check if client have jsessionid cookie, then proxy everything to tomcat as is, but if there are no cookie then take value from header x-auth-token and set it into jsessionid cookie, and after that proxy everything to tomcat.
Upvotes: 0
Views: 2305
Reputation: 15537
Try this:
location / {
if ($cookie_JSESSIONID = "") {
add_header Set-Cookie JSESSIONID=$http_x_auth_token;
}
proxy_pass <proto://tomcat_server_address:port>;
}
If your tomcat domain is different from the site domain, you may need to add additional parameters before the proxy_pass
parameter:
proxy_set_header Host <tomcat_domain>;
proxy_cookie_domain <tomcat_domain> <site_domain>;
Upvotes: 2