Enable Cross-Origin Support on YARN
You must enable Cross-Origin Resource Sharing (CORS) on YARN such that the corresponding services accept cross-origin requests from only selected domains. Enabling CORS also helps the YARN UI fetch data endpoints from the browser.
You must first enable CORS at the cluster level and then on individual components such as YARN.
- In Ambari Web, browse to Services > HDFS > Configs, then expand Advanced core-site.
-
Add the value
org.apache.hadoop.security.HttpCrossOriginFilterInitializer
to the existing set of values configured for the hadoop.http.filter.initializers property. -
Configure values for the following properties depending on your
requirements:
Property Description hadoop.http.cross-origin.allowed-headers Comma-separated list of headers allowed for cross-origin support. The default values are
X-Requested-With
,Content-Type
,Accept
,Origin
,WWW-Authenticate
,Accept-Encoding
, andTransfer-Encoding
.hadoop.http.cross-origin.allowed-origins Comma-separated list of origins allowed for cross-origin support. The default value is *. Mention only specific origins so that the services do not accept all the cross-origin requests.
hadoop.http.cross-origin.allowed-methods Comma-separated list of methods allowed for cross-origin support. The default values are
GET
,PUT
,POST
,OPTIONS
,HEAD
, andDELETE
.hadoop.http.cross-origin.max-age Number of seconds until when a preflight request can be cached. The default value is 1800 seconds.
- Click Save.
- Add a description of the modified HDFS configuration and click Save.
- In Ambari Web, browse to Services > YARN > Configs, then expand Advanced yarn-site.
-
Configure values for the following properties depending on your
requirements:
Property Description yarn.nodemanager.webapp.cross-origin.enabled Enable cross-origin support for the NodeManager. The default value is
true
.yarn.resourcemanager.webapp.cross-origin.enabled Enable cross-origin support for the ResourceManager. The default value is
true
.yarn.timeline-service.http-cross-origin.enabled Enable cross-origin support for the timeline service. The default value is
true
.NoteThe value of the hadoop.http.cross-origin.allowed-origins property inyarn-site.xml
overrides the value of the same property incore-site.xml
. You can configure the value of this property to allow access to specific domains; for example,regex:.*[.]hwx[.]site(:\d*)?
. - Click Save.
- Add a description of the modified YARN configuration and click Save.
- Restart the HDFS and YARN services.