Search code examples
nginxreverse-proxynginx-reverse-proxy

nginx reverse proxy add request cookie


I have to use reverse proxy for a project. I need to add request cookie in nginx.

The case like:

request comes with header. other servis want to this variable in cookie. I tried many way for resolve this problem. I did not manage to.

Anyone can help me ? Thanks


Solution

  • Do you want to move parameter from header to cookie? Try something like this:

    location / {
    ...
    proxy_set_header Cookie "MY_COOKIE_PARAM=${http_my_header_param}; ${http_cookie}";
    ...
    }