<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1471887336129_10375" dir="ltr"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10534">Hi All, </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10535"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10536"> I'm trying to implement SSO similar to this: </span></div><div id="yui_3_16_0_ym19_1_1471887336129_10375" dir="ltr"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10602">https://developers.shopware.com/blog/2015/03/02/sso-with-nginx-authrequest-module/ </span></div><div id="yui_3_16_0_ym19_1_1471887336129_10375" dir="ltr"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10604">however I am using node/passport/azure-ad for my authentication service. </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10537"><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10538"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10539">The issue I am running into is - how do I get the originally requested route /app1 when the subrequest returns a 401? I'd like to pass that along to the passport.js middleware as a parameter so it will redirect me properly after authentication (which involves several redirects). </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10540"><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10541"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10542">server { </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10543"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10544">    listen 80; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10545"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10546">    server_name localhost; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10547"><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10548"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10549">    error_page 401 /login; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10550"><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10551"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10552">    location /login { </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10553"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10554">        set $app //this is where I get stuck </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10555"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10556">        rewrite ^/login http://localhost:3200/login?appUrl=$app; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10557"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10558">    } </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10559"><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10560"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10561">    location /app1 { </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10562"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10563">        root /var/www/html; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10564"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10565">        index index.html index.htm index.nginx-debian.html; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10566"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10567">        auth_request /auth; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10568"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10569">    } </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10570"><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10571"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10572">    location /auth { </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10573"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10574">        proxy_pass http://localhost:3200/auth; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10575"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10576">        proxy_pass_request_body off; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10577"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10578">        proxy_set_header Content-Length ""; </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10579"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10580">    } </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10581"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10582">} </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10583"><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10584"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10585">I've tried returning the value from node as a custom header, tried $upstream_http_, $sent_http_, $http_, </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10586"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10587">Tried storing it as a session variable, but express sees the subrequest as a different session than navigating directly, etc. </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10588"><br>I've gone through the past couple years on the mailing list archive and didnt see anything. <br><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10589"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10590">Any help would be appreciated! </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10591"><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10592"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10593">Thanks </span><br style="clear: both; font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10594"><span style="font-family: Arial; font-size: medium;" id="yui_3_16_0_ym19_1_1471887336129_10595">Jason</span><br id="yui_3_16_0_ym19_1_1471887336129_10596"></div></div></body></html>