<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Splunk behind proxy - returning wrong context path  with 303 in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-behind-proxy-returning-wrong-context-path-with-303/m-p/70739#M990</link>
    <description>&lt;P&gt;Hello:&lt;/P&gt;

&lt;P&gt;My instance is running behind a proxy with root end point as  - say /mysplunkapp&lt;BR /&gt;
The configurations are done in web.conf file  correctly to reflect the root context path to /mysplunkapp&lt;/P&gt;

&lt;P&gt;The problem is while login into splunk.  From the firebug,   we see that there is 303 - "See Other" firing up.&lt;BR /&gt;
With this, the context path is lost and the proxy web server is not able to understand where to redirect the request to. &lt;BR /&gt;
Hence, users getting lost ( redirected to some other page on the proxy) .  This happens, on and off. Specifically, for sure for the first time login into Splunk.  &lt;/P&gt;

&lt;P&gt;I looked into the Splunk python code. But, could not locate where the login is handled.  Though I see login.html where FORM based auth is taken care..  I could not see the real issue in the code. I suspect its around redirect and return_to variable.&lt;/P&gt;

&lt;P&gt;In simple terms, whats expected is, after login into Splunk, the response should have  the path as   "/mysplunkapp"&lt;BR /&gt;
but, what is redirected is  just root  "/".&lt;BR /&gt;
Hence proxy is not able to understand where to redirect to?&lt;/P&gt;

&lt;P&gt;Any idea how to address this? &lt;/P&gt;

&lt;P&gt;thanks..&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2013 22:05:40 GMT</pubDate>
    <dc:creator>splunkears</dc:creator>
    <dc:date>2013-09-23T22:05:40Z</dc:date>
    <item>
      <title>Splunk behind proxy - returning wrong context path  with 303</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-behind-proxy-returning-wrong-context-path-with-303/m-p/70739#M990</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;

&lt;P&gt;My instance is running behind a proxy with root end point as  - say /mysplunkapp&lt;BR /&gt;
The configurations are done in web.conf file  correctly to reflect the root context path to /mysplunkapp&lt;/P&gt;

&lt;P&gt;The problem is while login into splunk.  From the firebug,   we see that there is 303 - "See Other" firing up.&lt;BR /&gt;
With this, the context path is lost and the proxy web server is not able to understand where to redirect the request to. &lt;BR /&gt;
Hence, users getting lost ( redirected to some other page on the proxy) .  This happens, on and off. Specifically, for sure for the first time login into Splunk.  &lt;/P&gt;

&lt;P&gt;I looked into the Splunk python code. But, could not locate where the login is handled.  Though I see login.html where FORM based auth is taken care..  I could not see the real issue in the code. I suspect its around redirect and return_to variable.&lt;/P&gt;

&lt;P&gt;In simple terms, whats expected is, after login into Splunk, the response should have  the path as   "/mysplunkapp"&lt;BR /&gt;
but, what is redirected is  just root  "/".&lt;BR /&gt;
Hence proxy is not able to understand where to redirect to?&lt;/P&gt;

&lt;P&gt;Any idea how to address this? &lt;/P&gt;

&lt;P&gt;thanks..&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2013 22:05:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-behind-proxy-returning-wrong-context-path-with-303/m-p/70739#M990</guid>
      <dc:creator>splunkears</dc:creator>
      <dc:date>2013-09-23T22:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk behind proxy - returning wrong context path  with 303</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-behind-proxy-returning-wrong-context-path-with-303/m-p/70740#M991</link>
      <description>&lt;P&gt;Debugged this extensively.  Finally, I did a hack. Hardcoded my root context path /mysplunkapp in the file account.py:login(..) method&lt;/P&gt;

&lt;P&gt;This works for me.&lt;/P&gt;

&lt;P&gt;File affected:&lt;BR /&gt;
../lib/python2.7/site-packages/splunk/appserver/mrsparkle/controllers/account.py&lt;/P&gt;

&lt;P&gt;@expose_page(must_login=False, methods=['GET','POST'], verify_session=False)&lt;BR /&gt;
    @lock_session&lt;BR /&gt;
    @set_cache_level('never')&lt;BR /&gt;
    def login(self, username=None, password=None, return_to=None, cval=None, **kwargs):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    #FIX  (1) line below 
    return_to = '/mysplunkapp/en-US/'    &amp;lt;&amp;lt;===

    # Force a refresh of startup info so that we know to
    # redirect if license stuff has expired.
    startup.initVersionInfo(force=True)

    updateCheckerBaseURL = self.getUpdateCheckerBaseURL()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;ps: Replace hardcoded value with cherrypy.config.get('root.endpoint') , if you didn't like hardcoding.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:50:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-behind-proxy-returning-wrong-context-path-with-303/m-p/70740#M991</guid>
      <dc:creator>splunkears</dc:creator>
      <dc:date>2020-09-28T14:50:34Z</dc:date>
    </item>
  </channel>
</rss>

