<?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 Re: Splunk JS Stack not working from external web page in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226941#M2921</link>
    <description>&lt;P&gt;FYI. Splunk SDK for JavaScript version 1.8.1 was just released. Not sure if it addresses anything here but I wanted to let you know.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Oct 2016 13:01:59 GMT</pubDate>
    <dc:creator>sloshburch</dc:creator>
    <dc:date>2016-10-21T13:01:59Z</dc:date>
    <item>
      <title>Splunk JS Stack not working from external web page.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226934#M2914</link>
      <description>&lt;P&gt;Hi, I am trying very hard to embed Splunk in an external webpage using Splunk JavaScript stack but no luck so far.&lt;/P&gt;
&lt;P&gt;I am trying a very simple example from here &lt;A href="http://dev.splunk.com/view/SP-CAAAEWS" target="_blank"&gt;http://dev.splunk.com/view/SP-CAAAEWS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Anyone had luck connecting to splunk from external webpages using SplunkJS?&lt;/P&gt;
&lt;P&gt;The difference from the example and my environment are &lt;STRONG&gt;Proxy&lt;/STRONG&gt; and &lt;STRONG&gt;Scheme&lt;/STRONG&gt; My environment is not https and there is no proxy.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&amp;gt;
    &amp;lt;title&amp;gt;Login Tests&amp;lt;/title&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;

    &amp;lt;link rel="stylesheet" type="text/css" href="static/splunkjs/css/bootstrap.css"/&amp;gt;
    &amp;lt;style type="text/css"&amp;gt;
        .fail{
            color: red;
        }
        .main-area {
            padding: 30px;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;div class="main-area"&amp;gt;
        &amp;lt;h2&amp;gt;Login Form&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;This page tests login and authentication. When you enter a 
            name and password, these credentials are used to log in 
            to Splunk.&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;If login is successful, a session key is returned and stored 
            in a cookie, along with the username. Then, you are redirected 
            to another page that uses the same session key.&amp;lt;/p&amp;gt;
        &amp;amp;lt;br/&amp;amp;gt;
        &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Username:&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;
        &amp;lt;input id="usernamebox" type="text" value="admin"&amp;gt;
        &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Password:&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;
        &amp;lt;input id="pwbox" type="password" value="mypassword"&amp;gt;
        &amp;amp;lt;br/&amp;amp;gt;
        &amp;lt;button class="btn" onclick="onLogin()"&amp;gt;Log in&amp;lt;/button&amp;gt;
        &amp;amp;lt;br/&amp;amp;gt;
        &amp;lt;div id="errorText"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;script src="static/splunkjs/config.js"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
        // Set the web site's base URL
        require.config({
            baseUrl: "/static"
        });

        // Log In button function
        function onLogin() {
            alert("Inside OnLogin");
            require([
                "jquery",
                "splunkjs/splunk",
            ], function($, jssdk) {
                alert('Inside Login');
                // Get the username and passwords
                var username = $("#usernamebox").val();
                var password = $("#pwbox").val();

                // Use the Splunk SDK for JavaScript to log in to Splunk

                // Create a Service object
                var http =  new jssdk.ProxyHttp("/proxy");
                var service = new jssdk.Service(http, {
                    username: username,
                    password: password,
                    scheme: "http",
                    host: "splunkdev", 
                    port: 8000
                });

                // Log in to Splunk
                service.login(function(err) {
                    alert('Inside Service Login');
                    // The session key and username are required for logging in
                    if (!err) {
                        var key = service.sessionKey;
                        // Save the session key and username in cookies
                        $.cookie("splunk_sessionkey", key);
                        $.cookie("splunk_username", username);

                        // Redirect to another page
                        window.location.href = "login_verify.html";  
                    }
                    else {
                        alert('Login Failed');
                        $("#errorText").empty().append("&amp;lt;p class='fail'&amp;gt;&amp;amp;lt;br/&amp;amp;gt;Login failed! See the console for error info.&amp;lt;/p&amp;gt;");
                        console.error("Login failed: ", err);
                    }              
                });
            });
        }   
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jun 2020 23:10:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226934#M2914</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2020-06-17T23:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226935#M2915</link>
      <description>&lt;P&gt;Remember that the SDKs use the splunkd REST endpoints. &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;You should see that the management interface in Splunk (also known as splunkd) is &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Admin/Changedefaultvalues#Change_network_ports"&gt;8089 by default&lt;/A&gt;. In your example, you changed the port to 8000 which is likely the default web port. That will not work. This must connect to the management interface port. &lt;/LI&gt;
&lt;LI&gt;I'm not sure you need the "/proxy" since there is no Splunk endpoint that uses that. I'll see if a peer can confirm.&lt;/LI&gt;
&lt;LI&gt;The &lt;CODE&gt;scheme&lt;/CODE&gt; needs to be &lt;CODE&gt;https&lt;/CODE&gt;. Even though splunkweb is http, you're connecting to splunkd which is &lt;CODE&gt;https&lt;/CODE&gt; by default. I highly doubt you went through the effort of disabling (if even possible) the splunkd https connection.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 18 Oct 2016 18:47:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226935#M2915</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-10-18T18:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226936#M2916</link>
      <description>&lt;P&gt;Hi Burch, &lt;/P&gt;

&lt;P&gt;I tried with https, 8089 port but no luck. I in fact tried all the combinations before posting it in the forum. I ran out of options now..&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 01:16:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226936#M2916</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-10-19T01:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226937#M2917</link>
      <description>&lt;P&gt;What was the error when you used https, 8089, and no '/proxy'? Please also include the error message that appeared in $SPLUNK_HOME/var/log/splunk/splunkd.log &lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 12:20:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226937#M2917</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-10-19T12:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226938#M2918</link>
      <description>&lt;P&gt;Hi Burch,&lt;/P&gt;

&lt;P&gt;I do not see the request reaching the server. There is no request information logged in splunkd.log.&lt;/P&gt;

&lt;P&gt;I am not able to attach screenshots. here are the error messages:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Code Snippet (with /proxy and https):

&amp;lt;script&amp;gt;
 splunkjs.config({
        proxyPath: '/proxy',
        scheme: 'https',
        host: 'splunkdev.com',
        port: 8089,
        authenticate: {username: 'admin', password: 'test123'}
    });
&amp;lt;/script&amp;gt;

Error message on js console:

mvc.js:8819 POST &lt;A href="http://localhost:6080/proxy/services/auth/login?output_mode=json" target="test_blank"&gt;http://localhost:6080/proxy/services/auth/login?output_mode=json&lt;/A&gt; 404 (Not Found)send @ mvc.js:8819ajax @ mvc.js:8249makeRequest @ mvc.js:24517request @ mvc.js:20231(anonymous function) @ mvc.js:19028post @ mvc.js:20166(anonymous function) @ mvc.js:19028login @ mvc.js:19746(anonymous function) @ mvc.js:19028authFunction @ mvc.js:70615loginLoad @ mvc.js:70634(anonymous function) @ mvc.js:70429execCb @ config.js:1636check @ config.js:872enable @ config.js:1143init @ config.js:780(anonymous function) @ config.js:1413
config.js:139 Uncaught Error: Login failed. Authenticate(done) received an error(anonymous function) @ mvc.js:70636(anonymous function) @ mvc.js:70617wrappedCallback @ mvc.js:19738wrappedCallback @ mvc.js:20212error @ mvc.js:24506(anonymous function) @ mvc.js:70831fire @ mvc.js:3161fireWith @ mvc.js:3273done @ mvc.js:8350callback @ mvc.js:8891


Code Snippet (with out proxy):

&amp;lt;script&amp;gt;
 splunkjs.config({
        proxyPath: '/',
        scheme: 'https',
        host: 'splunkdev.com',
        port: 8089,
        authenticate: {username: 'admin', password: 'test123'}
    });
&amp;lt;/script&amp;gt;

Error message on js console:

config.js:164 Uncaught Error: Load timeout for modules: splunkjs/ready!_unnormalized2,splunkjs/ready!
&lt;A href="http://requirejs.org/docs/errors.html#timeoutmakeError" target="test_blank"&gt;http://requirejs.org/docs/errors.html#timeoutmakeError&lt;/A&gt; @ config.js:164checkLoaded @ config.js:690(anonymous function) @ config.js:711
mvc.js:8819 OPTIONS &lt;A href="http://services/auth/login?output_mode=json" target="test_blank"&gt;http://services/auth/login?output_mode=json&lt;/A&gt; net::ERR_CONNECTION_TIMED_OUTsend @ mvc.js:8819ajax @ mvc.js:8249makeRequest @ mvc.js:24517request @ mvc.js:20231(anonymous function) @ mvc.js:19028post @ mvc.js:20166(anonymous function) @ mvc.js:19028login @ mvc.js:19746(anonymous function) @ mvc.js:19028authFunction @ mvc.js:70615loginLoad @ mvc.js:70634(anonymous function) @ mvc.js:70429execCb @ config.js:1636check @ config.js:872enable @ config.js:1143init @ config.js:780(anonymous function) @ config.js:1413
config.js:139 Uncaught Error: Login failed. Authenticate(done) received an error
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 14:37:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226938#M2918</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-10-19T14:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226939#M2919</link>
      <description>&lt;P&gt;So the first example shows a 404 (with proxy) so you're trying to reach something that's not there.&lt;/P&gt;

&lt;P&gt;If this is on your local, why are you using splunkdev.com? Why not localhost?&lt;/P&gt;

&lt;P&gt;In the second, I see the url after OPTIONS shows &lt;CODE&gt;&lt;A href="http://services/auth/login?output_mode=json" target="test_blank"&gt;http://services/auth/login?output_mode=json&lt;/A&gt;&lt;/CODE&gt;. I'm confused why the host:port portion is missing. &lt;/P&gt;

&lt;P&gt;The url that it should end up calling should be like:&lt;BR /&gt;
&lt;A href="https://localhost:8089/services/auth/login?output_mode=json"&gt;https://localhost:8089/services/auth/login?output_mode=json&lt;/A&gt;&lt;BR /&gt;
Notice the:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;https&lt;/LI&gt;
&lt;LI&gt;use of &lt;CODE&gt;localhost&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;port &lt;CODE&gt;8089&lt;/CODE&gt;, not &lt;CODE&gt;8000&lt;/CODE&gt; and not &lt;CODE&gt;6080&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;no &lt;CODE&gt;/proxy&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;You can validate this is the endpoint on your system by navigating to &lt;A href="https://localhost:8089/services/auth/login"&gt;https://localhost:8089/services/auth/login&lt;/A&gt; in your web browser.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 21:26:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226939#M2919</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-10-20T21:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226940#M2920</link>
      <description>&lt;P&gt;Burch,&lt;/P&gt;

&lt;P&gt;localhost and 6080 is the hostname and port number of my local tomcat server. splunkdev and 8089 are the server hostname and port number. &lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 12:49:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226940#M2920</guid>
      <dc:creator>friscos</dc:creator>
      <dc:date>2016-10-21T12:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226941#M2921</link>
      <description>&lt;P&gt;FYI. Splunk SDK for JavaScript version 1.8.1 was just released. Not sure if it addresses anything here but I wanted to let you know.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 13:01:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226941#M2921</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-10-21T13:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226942#M2922</link>
      <description>&lt;P&gt;Did a webex and discovered that this was not working because of the browsers security policies around &lt;A href="http://dev.splunk.com/view/javascript-sdk/SP-CAAAEWQ"&gt;Same Origin Policy&lt;/A&gt;. We verified this by running the node.exe that comes with the SDK and connecting to a local splunk install successfully.&lt;/P&gt;

&lt;P&gt;@friscos is now attempting &lt;A href="http://www.thegeekstuff.com/2016/09/disable-same-origin-policy/"&gt;http://www.thegeekstuff.com/2016/09/disable-same-origin-policy/&lt;/A&gt; to allow his browser to connect to his remote Splunk instance.&lt;/P&gt;

&lt;P&gt;Obviously the final solution must contain a proxy on the webserver to address this browser restriction in production.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 16:07:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226942#M2922</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-10-24T16:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226943#M2923</link>
      <description>&lt;P&gt;Update from our webex: The javascript SDK comes with a node server that can abstract the cross domain challenge. It's actually all explained in the dev docs @ &lt;A href="http://dev.splunk.com/view/javascript-sdk/SP-CAAAEWQ"&gt;http://dev.splunk.com/view/javascript-sdk/SP-CAAAEWQ&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 20:10:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226943#M2923</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-11-01T20:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226944#M2924</link>
      <description>&lt;P&gt;Hi SloshBurch ,&lt;BR /&gt;
I followed all the examples and its working fine with the node server.&lt;BR /&gt;
 How do I configure  it on IIS server to work as a Proxy for connecting to Splunk Web from outside? Can you please share settings on IIS server, if i need to add proxy-pass in web.conf, if there is any snippet that you can share?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 13:42:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226944#M2924</guid>
      <dc:creator>AshChakor</dc:creator>
      <dc:date>2019-04-30T13:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JS Stack not working from external web page</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226945#M2925</link>
      <description>&lt;P&gt;@AshChakor - My memory is failing me now (the rest of the thread was three years ago) . I can't speak to how to set it up on IIS (not my background). When I navigate to the web.conf spec file and search for &lt;CODE&gt;proxy&lt;/CODE&gt; a number of settings are discovered.  Although maybe your best luck will come from one of these pages: &lt;A href="https://docs.splunk.com/Special:SplunkSearch/docs?q=proxy"&gt;https://docs.splunk.com/Special:SplunkSearch/docs?q=proxy&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Sorry I can't be of more help here. Feel free to post a new question with your specifics to get more attention to your needs. Or a support ticket of course. Lastly, your account team might be able to provide more guidance.&lt;/P&gt;

&lt;P&gt;Sorry, I wish I was smarter &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 13:29:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JS-Stack-not-working-from-external-web-page/m-p/226945#M2925</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2019-06-07T13:29:25Z</dc:date>
    </item>
  </channel>
</rss>

