Security

Require.js with reverse proxy

Explorer

Hi team. I'm facing problems with my splunk app due to require.js, let me explain myself:
My app structure is like this:
.
├── CHANGELOG.md
├── LICENSE
├── README.md
└── SplunkAppForWazuh
├── appserver
│   ├── controllers
│   │   ├── agents.py
│   │   ├── cluster.py
│   │   └── manager.py
│   └── static
│   ├── css
│   │   ├── images
│   │   │   ├── sortascdisabled.png
│   │   │   ├── sortasc.png
│   │   │   ├── sort
both.png
│   │   │   ├── sortdescdisabled.png
│   │   │   └── sortdesc.png
│   │   ├── styles
│   │   │   ├── table
decorations.css
│   │   │   ├── toast.css
│   │   │   └── wazuhdecorations.css
│   │   └── thirdPartyStyles
│   │   └── font-awesome
│   │   ├── css
│   │   │   ├── font-awesome.css
│   │   │   └── font-awesome.min.css
│   │   └── fonts
│   │   ├── FontAwesome.otf
│   │   ├── fontawesome-webfont.eot
│   │   ├── fontawesome-webfont.svg
│   │   ├── fontawesome-webfont.ttf
│   │   ├── fontawesome-webfont.woff
│   │   └── fontawesome-webfont.woff2
│   ├── js
│   │   ├── directives
│   │   │   ├── agentsTable.js
│   │   │   ├── selectedCredentialsDirective.js
│   │   │   ├── tableView.js
│   │   │   └── toaster.js
│   │   ├── services
│   │   │   ├── apiService.js
│   │   │   ├── credentialService.js
│   │   │   ├── indexService.js
│   │   │   ├── localStorage.js
│   │   │   └── promisedReq.js
│   │   └── viewControllers
│   │   ├── agentsConfiguration.js
│   │   ├── agent
summary.js
│   │   ├── audit.js
│   │   ├── cis.js
│   │   ├── configuration.js
│   │   ├── fim.js
│   │   ├── gdpr.js
│   │   ├── general.js
│   │   ├── groups.js
│   │   ├── logs.js
│   │   ├── managerdecoders.js
│   │   ├── manager
ruleset.js
│   │   ├── managerstatus.js
│   │   ├── openscap.js
│   │   ├── overview
audit.js
│   │   ├── overviewfim.js
│   │   ├── overview
gdpr.js
│   │   ├── overviewpcidss.js
│   │   ├── overviewpolicymonitoring.js
│   │   ├── overviewscap.js
│   │   ├── pcidss.js
│   │   ├── selectIndex.js
│   │   ├── settings.js
│   │   └── wazuh
alerts.js
│   └── views
│   ├── agentConfigurationViews
│   │   ├── ciscat.html
│   │   ├── fileIntegrity.html
│   │   ├── logCollection.html
│   │   ├── openSCAP.html
│   │   ├── policyMonitoring.html
│   │   ├── remoteCommand.html
│   │   └── syscollector.html
│   └── managerConfigurationViews
│   ├── auth.html
│   ├── cluster.html
│   ├── command.html
│   ├── global.html
│   ├── remote.html
│   ├── rootcheck.html
│   ├── ruleset.html
│   └── syscheck.html
├── bin
│   ├── getagentscheck.py
│   ├── getagentsfromgroup.py
│   ├── get
agentsinfo.py
│   ├── get
agents.py
│   ├── getagentsstatus.py
│   ├── getagentssummary.py
│   ├── getcurrentversion.py
│   ├── getdecoders.py
│   ├── get
filecontent.py
│   ├── get
filesfromgroup.py
│   ├── getgroups.py
│   ├── get
managerlogs.py
│   ├── get
managerstatus.py
│   ├── get
ruleset.py
│   ├── README
│   └── splunklib
│   ├── binding.py
│   ├── client.py
│   ├── data.py
│   ├── init.py
│   ├── ordereddict.py
│   ├── results.py
│   └── six.py
├── default
│   ├── app.conf
│   ├── collections.conf
│   ├── commands.conf
│   ├── config.conf
│   ├── data
│   │   └── ui
│   │   ├── html
│   │   │   ├── abgeneral.html
│   │   │   ├── agents
configuration.html
│   │   │   ├── agentssummary.html
│   │   │   ├── audit.html
│   │   │   ├── cis.html
│   │   │   ├── configuration.html
│   │   │   ├── fim.html
│   │   │   ├── gdpr.html
│   │   │   ├── groups.html
│   │   │   ├── logs.html
│   │   │   ├── manager
decoders.html
│   │   │   ├── managerruleset.html
│   │   │   ├── manager
status.html
│   │   │   ├── openscap.html
│   │   │   ├── overviewaudit.html
│   │   │   ├── overview
fim.html
│   │   │   ├── overviewgdpr.html
│   │   │   ├── overview
pcidss.html
│   │   │   ├── overview
policymonitoring.html
│   │   │   ├── overview
scap.html
│   │   │   ├── pcidss.html
│   │   │   ├── selectindex.html
│   │   │   ├── settings.html
│   │   │   └── wazuh
alerts.html
│   │   ├── nav
│   │   │   └── default.xml
│   │   └── views
│   │   └── README
│   ├── indexes.conf
│   ├── inputs.conf
│   ├── package.conf
│   ├── props.conf
│   ├── transforms.conf
│   └── web.conf
├── lookups
│   ├── gdpr.csv
│   └── pci1.csv
├── metadata
│   ├── default.meta
│   └── local.meta
└── static
├── appIcon2x.png
├── appIconAlt
2x.png
├── appIconAlt.png
├── appIcon.png
├── appLogo_2x.png
├── appLogo.png
└── screenshot.png

And the way I'm using for importing modules with require is the following, for example in settings.js:

require([
"splunkjs/mvc",
"splunkjs/mvc/utils",
"splunkjs/mvc/simplexml",
"splunkjs/mvc/simplexml/dashboardview",
"underscore",
"splunkjs/mvc/tokenutils",
"jquery",
"splunkjs/mvc/layoutview",
"splunkjs/mvc/simplexml/dashboardview",
"/static/app/SplunkAppForWazuh/js/services/credentialService.js",
"/static/app/SplunkAppForWazuh/js/services/apiService.js",
"/static/app/SplunkAppForWazuh/js/services/indexService.js",
"/static/app/SplunkAppForWazuh/js/directives/toaster",
"splunkjs/mvc/simplexml/searcheventhandler",
"splunkjs/mvc/simpleform/input/dropdown",
"splunkjs/mvc/searchmanager",
"splunkjs/mvc/simplexml/urltokenmodel",
"splunkjs/mvc/simpleform/formutils"

],
function (
mvc,
utils,
DashboardController,
Dashboard,
_,
TokenUtils,
$,
LayoutView,
Dashboard,
CredentialService,
ApiService,
IndexService,
Toast,
SearchEventHandler,
DropdownInput,
SearchManager,
UrlTokenModel,
FormUtils
) { ...

As you can see, I'm importing my own modules by hardcoding the URL like this:
...
"/static/app/SplunkAppForWazuh/js/services/indexService.js",
...

And works great, I access my app in this url: http://IP:8000/en-US/app/SplunkAppForWazuh/settings and al dependencies works fine,
but when accessing via a reverse proxy, I get 404s in the reverse proxy that it cannot find the js files.

´´´

tail -F /var/log/nginx/*.log | grep -i wazuh

clientuserip - - [13/Jun/2018:08:16:31 -0400] "GET /splunk/en-GB/splunkd/raw/servicesNS/mysplunkusername/SplunkAppForWazuh/static/appIconAlt.png HTTP/1.1" 200 2082 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
clientuserip - - [13/Jun/2018:08:16:33 -0400] "GET /splunk/en-GB/app/SplunkAppForWazuh HTTP/1.1" 303 129 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:33 -0400] "GET /splunk/en-GB/app/SplunkAppForWazuh/API HTTP/1.1" 200 1410 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
clientuserip - - [13/Jun/2018:08:16:33 -0400] "GET /splunk//en-GB/static/@6EE0DA5BC97D7879008A1F199F82807231E52F81507E4FF3E4B5145031DDA25C/build/css/bootstrap-enterprise.css HTTP/1.1" 200 24686 "https://proxy_ip_address/splunk/en-GB/app/SplunkAppForWazuh/API" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:33 -0400] "GET /splunk//en-GB/static/@6EE0DA5BC97D7879008A1F199F82807231E52F81507E4FF3E4B5145031DDA25C/css/build/pages/dashboard-simple-bootstrap.min.css HTTP/1.1" 200 169 "https://proxyipaddress/splunk/en-GB/app/SplunkAppForWazuh/API" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
clientuserip - - [13/Jun/2018:08:16:33 -0400] "GET /splunk//en-GB/static/@6EE0DA5BC97D7879008A1F199F82807231E52F81507E4FF3E4B5145031DDA25C/app/SplunkAppForWazuh/css/styles/toast.css HTTP/1.1" 200 3264 "https://proxy_ip_address/splunk/en-GB/app/SplunkAppForWazuh/API" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:33 -0400] "GET /splunk//en-GB/static/@6EE0DA5BC97D7879008A1F199F82807231E52F81507E4FF3E4B5145031DDA25C/app/SplunkAppForWazuh/css/styles/wazuhdecorations.css HTTP/1.1" 200 1031 "https://proxy_ip_address/splunk/en-GB/app/SplunkAppForWazuh/API" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:33 -0400] "GET /splunk//en-GB/static/@6EE0DA5BC97D7879008A1F199F82807231E52F81507E4FF3E4B5145031DDA25C/app/SplunkAppForWazuh/js/viewControllers/APIconf.js HTTP/1.1" 200 3298 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
clientuserip - - [13/Jun/2018:08:16:34 -0400] "GET /splunk//en-GB/splunkd/
raw/services/apps/local/SplunkAppForWazuh?outputmode=json&=1528892194220 HTTP/1.1" 200 773 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:34 -0400] "GET /splunk//en-GB/splunkd/raw/servicesNS/mysplunkusername/SplunkAppForWazuh/data/ui/times?outputmode=json&count=-1&=1528892194224 HTTP/1.1" 200 1959 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:34 -0400] "GET /splunk/en-GB/splunkd/raw/servicesNS/mysplunkusername/SplunkAppForWazuh/data/ui/views/API?outputmode=json&=1528892194226 HTTP/1.1" 200 1886 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:34 -0400] "GET /splunk//en-GB/splunkd/raw/servicesNS/mysplunkusername/SplunkAppForWazuh/configs/conf-visualizations?outputmode=json&search=disabled%3D0&count=0&=1528892194229 HTTP/1.1" 200 275 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:34 -0400] "GET /splunk/en-GB/app/SplunkAppForWazuh/js/customViews/toaster.js HTTP/1.1" 404 1401 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
clientuserip - - [13/Jun/2018:08:16:34 -0400] "GET /splunk/en-GB/app/SplunkAppForWazuh/js/utilLib/promisedReq.js HTTP/1.1" 404 1401 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
client
userip - - [13/Jun/2018:08:16:34 -0400] "GET /splunk/en-GB/app/SplunkAppForWazuh/js/utilLib/services.js HTTP/1.1" 404 1401 "-" "Mozilla/5.0 (X11; Linux x8664) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
```

Notice that "GET /splunk/en-GB/app/SplunkAppForWazuh/js/utilLib/services.js HTTP/1.1" - 404

Any ideas? Thank you so much!

Labels (1)
0 Karma

Engager

Hi, I am facing the same problem.
Please, have you found a solution?

Thanks in advance.

0 Karma