Skip to content

Commit aadc13d

Browse files
author
Karl Stoney
committed
fixed cross-domain issue with Banana and Solr
1 parent edc225e commit aadc13d

File tree

7 files changed

+247
-14
lines changed

7 files changed

+247
-14
lines changed

banana/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
sed -i -e "s,solr: \"/.*/\",solr: \"$SOLR_HOST:$SOLR_PORT/$SOLR_DOMAIN\",g" /opt/banana/src/config.js
5-
sed -i -e "s,\"server\": \"/.*/\",\"server\": \"$SOLR_HOST:$SOLR_PORT/$SOLR_DOMAIN\",g" /opt/banana/src/app/dashboards/default.json
5+
sed -i -e "s,\"server\": \"/.*/\",\"server\": \"$CLIENT_SOLR_HOST:$CLIENT_SOLR_PORT/$SOLR_DOMAIN\",g" /opt/banana/src/app/dashboards/default.json
66

77
cd /opt/banana
88
./node_modules/http-server/bin/http-server -a 0.0.0.0 -p 8000

compose.hbase.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ services:
4444
mem_limit: 512m
4545
memswap_limit: 1g
4646
environment:
47-
- HBASE_CONF_QUORUM=hbase-zookeeper
48-
- HBASE_CONF_ROOTDIR=hdfs://namenode:8020/hbase
4947
# docker-compose networking is flakey, I've added a script
5048
# which does DNS looking for any HOST_ENTRY_* ENV variables
5149
# and adds it to the hostfile for the container, thus bypassing
5250
# the DNS lookup which adds the project network name
5351
- HOST_ENTRY_1=hbase-regionserver
5452
ports:
5553
- 17001:16010
54+
env_file:
55+
- ./stack.env
5656

5757
thrift:
5858
image: karlstoney/hbase

compose.other.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ services:
4343
environment:
4444
- SOLR_HOST=solr
4545
- SOLR_PORT=8983
46+
- CLIENT_SOLR_HOST=127.0.0.1
47+
- CLIENT_SOLR_PORT=17008
4648
ports:
4749
- 17009:8000 # UI
4850
env_file:

hue/pseudo-distributed.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,10 +1036,10 @@
10361036
## archive_upload_tempdir=/tmp
10371037

10381038
# Show Download Button for HDFS file browser.
1039-
## show_download_button=false
1039+
show_download_button=true
10401040

10411041
# Show Upload Button for HDFS file browser.
1042-
## show_upload_button=false
1042+
show_upload_button=true
10431043

10441044
## Flag to enable the extraction of a uploaded archive in HDFS.
10451045
# enable_extract_uploaded_archive=false

solr/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ WORKDIR /opt/solr
2020
VOLUME /data
2121
EXPOSE 8983
2222

23+
# Enable CORS
24+
COPY web.xml /opt/solr/server/solr-webapp/webapp/WEB-INF/web.xml
25+
2326
HEALTHCHECK CMD curl -f http://localhost:8983/ || exit 1
2427
COPY run.sh /usr/local/bin/run.sh
2528
CMD ["/usr/local/bin/run.sh"]

solr/web.xml

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
21+
version="2.5"
22+
metadata-complete="true"
23+
>
24+
25+
26+
<!-- Uncomment if you are trying to use a Resin version before 3.0.19.
27+
Their XML implementation isn't entirely compatible with Xerces.
28+
Below are the implementations to use with Sun's JVM.
29+
<system-property javax.xml.xpath.XPathFactory=
30+
"com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"/>
31+
<system-property javax.xml.parsers.DocumentBuilderFactory=
32+
"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
33+
<system-property javax.xml.parsers.SAXParserFactory=
34+
"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"/>
35+
-->
36+
37+
<!-- People who want to hardcode their "Solr Home" directly into the
38+
WAR File can set the JNDI property here...
39+
-->
40+
<!--
41+
<env-entry>
42+
<env-entry-name>solr/home</env-entry-name>
43+
<env-entry-value>/put/your/solr/home/here</env-entry-value>
44+
<env-entry-type>java.lang.String</env-entry-type>
45+
</env-entry>
46+
-->
47+
48+
<!-- Enable CORS -->
49+
<filter>
50+
<filter-name>cross-origin</filter-name>
51+
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
52+
<init-param>
53+
<param-name>allowedOrigins</param-name>
54+
<param-value>http://127.0.0.1*,http://localhost*</param-value>
55+
</init-param>
56+
<init-param>
57+
<param-name>allowedMethods</param-name>
58+
<param-value>GET,POST,DELETE,PUT,HEAD,OPTIONS</param-value>
59+
</init-param>
60+
<init-param>
61+
<param-name>allowedHeaders</param-name>
62+
<param-value>origin, content-type, cache-control, accept, options, authorization, x-requested-with</param-value>
63+
</init-param>
64+
<init-param>
65+
<param-name>supportsCredentials</param-name>
66+
<param-value>true</param-value>
67+
</init-param>
68+
<init-param>
69+
<param-name>chainPreflight</param-name>
70+
<param-value>false</param-value>
71+
</init-param>
72+
</filter>
73+
74+
<filter-mapping>
75+
<filter-name>cross-origin</filter-name>
76+
<url-pattern>/*</url-pattern>
77+
</filter-mapping>
78+
79+
<!-- Any path (name) registered in solrconfig.xml will be sent to that filter -->
80+
<filter>
81+
<filter-name>SolrRequestFilter</filter-name>
82+
<filter-class>org.apache.solr.servlet.SolrDispatchFilter</filter-class>
83+
<!--
84+
Exclude patterns is a list of directories that would be short circuited by the
85+
SolrDispatchFilter. It includes all Admin UI related static content.
86+
NOTE: It is NOT a pattern but only matches the start of the HTTP ServletPath.
87+
-->
88+
<init-param>
89+
<param-name>excludePatterns</param-name>
90+
<param-value>/css/.+,/js/.+,/img/.+,/tpl/.+</param-value>
91+
</init-param>
92+
</filter>
93+
94+
<filter-mapping>
95+
<!--
96+
NOTE: When using multicore, /admin JSP URLs with a core specified
97+
such as /solr/coreName/admin/stats.jsp get forwarded by a
98+
RequestDispatcher to /solr/admin/stats.jsp with the specified core
99+
put into request scope keyed as "org.apache.solr.SolrCore".
100+
101+
It is unnecessary, and potentially problematic, to have the SolrDispatchFilter
102+
configured to also filter on forwards. Do not configure
103+
this dispatcher as <dispatcher>FORWARD</dispatcher>.
104+
-->
105+
<filter-name>SolrRequestFilter</filter-name>
106+
<url-pattern>/*</url-pattern>
107+
</filter-mapping>
108+
109+
<servlet>
110+
<servlet-name>LoadAdminUI</servlet-name>
111+
<servlet-class>org.apache.solr.servlet.LoadAdminUiServlet</servlet-class>
112+
</servlet>
113+
114+
<!-- Remove in Solr 5.0 -->
115+
<!-- This sends SC_MOVED_PERMANENTLY (301) for resources that changed in 4.0 -->
116+
<servlet>
117+
<servlet-name>RedirectOldAdminUI</servlet-name>
118+
<servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
119+
<init-param>
120+
<param-name>destination</param-name>
121+
<param-value>${context}/#/</param-value>
122+
</init-param>
123+
</servlet>
124+
125+
<servlet>
126+
<servlet-name>RedirectOldZookeeper</servlet-name>
127+
<servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
128+
<init-param>
129+
<param-name>destination</param-name>
130+
<param-value>${context}/admin/zookeeper</param-value>
131+
</init-param>
132+
</servlet>
133+
134+
<servlet>
135+
<servlet-name>RedirectLogging</servlet-name>
136+
<servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
137+
<init-param>
138+
<param-name>destination</param-name>
139+
<param-value>${context}/#/~logging</param-value>
140+
</init-param>
141+
</servlet>
142+
143+
<servlet>
144+
<servlet-name>SolrRestApi</servlet-name>
145+
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
146+
<init-param>
147+
<param-name>org.restlet.application</param-name>
148+
<param-value>org.apache.solr.rest.SolrSchemaRestApi</param-value>
149+
</init-param>
150+
</servlet>
151+
152+
<servlet-mapping>
153+
<servlet-name>RedirectOldAdminUI</servlet-name>
154+
<url-pattern>/admin/</url-pattern>
155+
</servlet-mapping>
156+
<servlet-mapping>
157+
<servlet-name>RedirectOldAdminUI</servlet-name>
158+
<url-pattern>/admin</url-pattern>
159+
</servlet-mapping>
160+
<servlet-mapping>
161+
<servlet-name>RedirectOldZookeeper</servlet-name>
162+
<url-pattern>/zookeeper.jsp</url-pattern>
163+
</servlet-mapping>
164+
<servlet-mapping>
165+
<servlet-name>RedirectOldZookeeper</servlet-name>
166+
<url-pattern>/zookeeper</url-pattern>
167+
</servlet-mapping>
168+
<servlet-mapping>
169+
<servlet-name>RedirectLogging</servlet-name>
170+
<url-pattern>/logging</url-pattern>
171+
</servlet-mapping>
172+
173+
<servlet-mapping>
174+
<servlet-name>LoadAdminUI</servlet-name>
175+
<url-pattern>/old.html</url-pattern>
176+
</servlet-mapping>
177+
178+
<servlet-mapping>
179+
<servlet-name>LoadAdminUI</servlet-name>
180+
<url-pattern>/index.html</url-pattern>
181+
</servlet-mapping>
182+
183+
<servlet-mapping>
184+
<servlet-name>SolrRestApi</servlet-name>
185+
<url-pattern>/schema/*</url-pattern>
186+
</servlet-mapping>
187+
188+
<mime-mapping>
189+
<extension>.xsl</extension>
190+
<!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
191+
<mime-type>application/xslt+xml</mime-type>
192+
</mime-mapping>
193+
194+
<welcome-file-list>
195+
<welcome-file>index.html</welcome-file>
196+
</welcome-file-list>
197+
198+
<!-- Get rid of error message -->
199+
<security-constraint>
200+
<web-resource-collection>
201+
<web-resource-name>Disable TRACE</web-resource-name>
202+
<url-pattern>/</url-pattern>
203+
<http-method>TRACE</http-method>
204+
</web-resource-collection>
205+
<auth-constraint/>
206+
</security-constraint>
207+
<security-constraint>
208+
<web-resource-collection>
209+
<web-resource-name>Enable everything but TRACE</web-resource-name>
210+
<url-pattern>/</url-pattern>
211+
<http-method-omission>TRACE</http-method-omission>
212+
</web-resource-collection>
213+
</security-constraint>
214+
215+
</web-app>

stack.env

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,36 @@ CORE_CONF_hadoop_http_staticuser_user=root
33
CORE_CONF_hadoop_proxyuser_hue_hosts=*
44
CORE_CONF_hadoop_proxyuser_hue_groups=*
55

6+
# HDFS Configuration
67
HDFS_CONF_dfs_webhdfs_enabled=true
78
HDFS_CONF_dfs_permissions_enabled=false
89

10+
# HBase configuration
911
HBASE_CONF_QUORUM=hbase-zookeeper
1012
HBASE_CONF_ROOTDIR=hdfs://namenode:8020/hbase
1113

12-
YARN_CONF_yarn_log___aggregation___enable=true
14+
# YARN basic settings
15+
YARN_CONF_yarn_resourcemanager_hostname=resourcemanager
16+
YARN_CONF_yarn_resourcemanager_scheduler_address=resourcemanager:8030
17+
YARN_CONF_yarn_resourcemanager_resource__tracker_address=resourcemanager:8031
18+
YARN_CONF_yarn_resourcemanager_address=resourcemanager:8032
19+
20+
# Allow resource manager to restore state when starting
1321
YARN_CONF_yarn_resourcemanager_recovery_enabled=true
1422
YARN_CONF_yarn_resourcemanager_store_class=org.apache.hadoop.yarn.server.resourcemanager.recovery.FileSystemRMStateStore
1523
YARN_CONF_yarn_resourcemanager_fs_state___store_uri=/rmstate
16-
YARN_CONF_yarn_nodemanager_remote___app___log___dir=/app-logs
24+
25+
# Enable log aggregation to the history server
26+
YARN_CONF_yarn_log___aggregation___enable=false
1727
YARN_CONF_yarn_log_server_url=http://historyserver:8188/applicationhistory/logs/
18-
YARN_CONF_yarn_timeline___service_enabled=true
19-
YARN_CONF_yarn_timeline___service_generic___application___history_enabled=true
20-
YARN_CONF_yarn_resourcemanager_system___metrics___publisher_enabled=true
21-
YARN_CONF_yarn_resourcemanager_hostname=resourcemanager
28+
29+
# Where to aggregate logs to
30+
YARN_CONF_yarn_nodemanager_remote___app___log___dir=/app-logs
31+
32+
# Enable system metrics to the history server
33+
YARN_CONF_yarn_resourcemanager_system___metrics___publisher_enabled=false
34+
35+
# Enable entities and events to the timeline server
36+
YARN_CONF_yarn_timeline___service_enabled=false
2237
YARN_CONF_yarn_timeline___service_hostname=historyserver
23-
YARN_CONF_yarn_resourcemanager_address=resourcemanager:8032
24-
YARN_CONF_yarn_resourcemanager_scheduler_address=resourcemanager:8030
25-
YARN_CONF_yarn_resourcemanager_resource__tracker_address=resourcemanager:8031
38+
YARN_CONF_yarn_timeline___service_generic___application___history_enabled=true

0 commit comments

Comments
 (0)