This section describes how to configure response headers for REST API servers used in Hive WebHCat and the HiveServer2 web UI.
/opt/mapr/hive/hive-<version>/conf/headres.xmlheadres.xml file contains the following
headers:<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="X-Content-Type-Options">nosniff</entry>
<entry key="X-XSS-Protection">1; mode=block</entry>
<entry key="Strict-Transport-Security">max-age=31536000; includeSubDomains</entry>
<entry key="Content-Security-Policy">default-src https:</entry>
</properties>
This table describes each header:
| Header | Description | Default Value |
|---|---|---|
| X-XSS-Protection | Stops pages from loading when reflected cross-site scripting (XSS) is detected. Supported by IE, Chrome, and Safari. | 1: mode=block |
| X-Content-Type-Options | Indicates that the MIME types advertised in the Content-Type
headers should not be changed and should be followed. |
nosniff |
| Strict-Transport-Security | Tells all browsers that the website should only be accessed using HTTPS instead of using HTTP. | max-age=31536000;includeSubDomains |
| Content-Security-Policy | Allows web-site administrators to control resources the user agent is allowed to load for a given page. This helps guard against cross-site scripting attacks (XSS). | default-src https: |
webhcat-site.xml file, and replace <version> with
your Hive
version:<property>
<name>templeton.jetty.response.headers.file</name>
<value>/opt/mapr/hive/hive-<version>/conf/headers.xml</value>
</property>
< HTTP/1.1 200 OK
< Date: Thu, 03 Oct 2019 11:35:39 GMT
< Set-Cookie: hadoop.auth="u=mapr&p=mapr&t=multiauth&e=1570138539451&s=CpX+tI7sScnnSUZpA1Kdf+7hamM="; Path=/; Domain=.cluster.com; Expires=Thu, 03-Oct-2019 21:35:39 GMT; Secure; HttpOnly
< Content-Security-Policy: default-src https:
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Strict-Transport-Security: max-age=31536000
< Content-Type: application/json
< Transfer-Encoding: chunked
< Server: Jetty(9.4.19.v20190610)
hive-site.xml file, replacing <version> with your
Hive
version:<property>
<name>hive.server2.webui.jetty.response.headers.file</name>
<value>/opt/mapr/hive/hive-<version>/conf/headers.xml</value>
</property>
Then restart HiveServer2.
headers.xml file,
and add Custom-header as
follows:<entry key="Custom-header">custom-value</entry>/opt/mapr/server/configure.sh -R