Reading post body in Nginx is downloading a DMS file

892 views Asked by At

Following is my scenario: When user hits http://mypage.sso.com (my sso endpoint) it will authenticate the user and will do a POST request to my site (https://mypage.com) with the authentication token in POST body. Iam trying to read the POST body in nginx and store the $response_body in cookie and start my angular application(i.e index.html). I have done the following configuration in my Nginx conf file (Nginx version 1.11.2)

location / {        
                 root    /app/UI/dist/public/;
                 index  index.html;
                 proxy_http_version 1.1;
                 proxy_set_header Host 127.0.0.1;
                 proxy_pass $scheme://127.0.0.1:80/auth;
                 add_header Set-Cookie lcid='$request_body';
                 error_page 405 =200 $uri;
    }
location /auth{
        return 200;
}

Now when user hits mypage.sso.com its downloading a DMS file and not redirecting to my page(mypage.com). But I see that cookie is properly set with auth token(taken from post body)(I could see this with already opened mypage.com). When I remove proxy_pass $scheme://127.0.0.1:80/auth; from my Nginx conf sso endpoint is properly redirecting to mypage.com but the $request_body is empty and hence my cookie is also set to empty value. What change should I do to properly set my cookie with POST body data and redirect to mypage.com and avoid downloading DMS file.

0

There are 0 answers