NGINX Headers

For a variety of reasons you may want to configure nginx to set certain headers when using SevOne Data Insight. This can also be used to nullify large headers.

Create Subjects Directory

  1. Create kubeobjects directory.
    mkdir /opt/SevOne/kubeobjects

Create custom-headers.yaml

  1. Determine the headers you want to change and create a file, custom-headers.yaml file.

    Create /opt/SevOne/kubeobjects/custom-headers.yaml file

    touch /opt/SevOne/kubeobjects/custom-headers.yaml
  2. Add the following contents with your custom headers set under the data section.

    Create /opt/SevOne/kubeobjects/custom-headers.yaml file

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: custom-headers
      namespace: default
    data:
      X-Different-Name: "true"
      X-Request-Start: t=${msec}
      X-Using-Nginx-Controller: "true"  

Update Ingress Configuration

  1. Using a text editor of your choice, edit /opt/SevOne/chartconfs/ingress_custom.yaml file to set environment variable controller and then, save it.
    Important: If /opt/SevOne/chartconfs/ingress_custom.yaml file does not exist, please create it.
    touch /opt/SevOne/chartconfs/ingress_custom.yaml`
    controller:
      config:
        proxy-set-headers: "default/custom-headers"
Attention: To set the headers for the response, replace the step above with add-headers. i.e.,

controller:
  config:
    add-headers: "default/custom-headers"
The following headers will be added to the response.

more_set_headers "Cache-Control: no-store";
more_set_headers "Content-Security-Policy: frame-ancestors 'none'";
more_set_headers "X-Content-Type-Options: nosniff";
more_set_headers "X-Different-Name: true";
more_set_headers "X-Frame-Options: DENY";
proxy-set-headers applies to internal proxy headers and not for the response.

Update Ansible Inventory

  1. Using a text editor of your choice, edit /etc/ansible/group_vars/all/custom-headers.yaml file to set environment variable kube_object_ingress and then, save it.
    Important: If /etc/ansible/group_vars/all/custom-headers.yaml file does not exist, please create it.
    touch /etc/ansible/group_vars/all/custom-headers.yaml`
    kube_object_ingress:
      enabled: true
      files:
      - /opt/SevOne/kubeobjects/custom-headers.yaml

Force Nginx Config Reload

When checking the nginx config, you may find that the custom headers configmap and the configuration differ. This typically happens based on which files are loaded when bringing up SevOne Data Insight.

  1. To force the nginx config to reload, change the ingress controller config map.
    kubectl edit cm ingress-ingress-nginx-controller

    This will open the NGINX config file in text editor, vi. Find the data section and change variable keep-alive-requests.

    data:
      keep-alive-requests: "10001"
  2. To save and exit the file, enter :wq!
  3. Kubernetes will automatically regenerate NGINX's config.