Configure Cross-Origin Support for YARN UIs and REST APIs

Cross-Origin Resource Sharing (CORS) is enabled by default on YARN so 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.

CORS is enabled at cluster level and then on individual components such as YARN. If you want to set other values than the default ones, use safety valves in Cloudera Manager to configure the CORS configuration properties.

  1. In the Cloudera Manager, select the YARN service.
  2. Click the Configuration tab.
  3. Search for core-site.xml.
  4. Find YARN Service Advanced Configuration Snippet (Safety Valve) for core-site.xml.
  5. Click on the plus icon to add and configure the following properties :
    Property Default value Description
    hadoop.http.cross-origin.allowed-origins regex:.*[.]subdomain[.]example[.]com(;\d+)?.*

    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 GET, PUT, POST, OPTIONS, HEAD, DELETE

    Comma-separated list of methods allowed for cross-origin support.

    hadoop.http.cross-origin.allowed-headers X-Requested-With, Content-Type, Accept, Origin, WWW-Authenticate, Accept-Encoding, Transfer-Encoding

    Comma-separated list of headers allowed for cross-origin support.

    hadoop.http.cross-origin.max-age 180

    Number of seconds until when a preflight request can be cached.

  6. Click Save Changes.
  7. In the Cloudera Manager, select the YARN service.
  8. Click the Configuration tab.
  9. Search for yarn-site.xml.
  10. Find the YARN Service Advanced Configuration Snippet (Safety Valve) for yarn-site.xml.
  11. Click on the plus icon to add and configure the cross-origin.enabled properties:
    Property Default value Description
    yarn.nodemanager.webapp.cross-origin.enabled true

    Enable cross-origin support for the NodeManager.

    yarn.resourcemanager.webapp.cross-origin.enabled true

    Enable cross-origin support for the ResourceManager.

    yarn.timeline-service.http-cross-origin.enabled true

    Enable cross-origin support for the timeline service.

  12. Click Save Changes.
  13. Restart the HDFS and YARN services.