Skip to content

Security response headers

Ingress can attach profile-based HTTP security headers after a route match: HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Content-Security-Policy, and CORS (including OPTIONS preflight).

Configure a global baseline under security:, Host-level overrides under rules[].security, and Path-level overrides under paths[].security. Fields merge in order: global → Host → Path.

Profiles

ProfileTypical useHSTSFrameCORS
strictWeb apps, admin UIautoDENYoff
apiREST / JSON APIsautoDENYon (requires cors.origins)
embeddablePages allowed in iframesautoSAMEORIGINoff
offDisabled

HSTS auto sends Strict-Transport-Security only when the request is HTTPS (direct TLS or X-Forwarded-Proto: https).

Example

yaml
security:
  profile: strict

rules:
  - host: api.example.com
    security:
      profile: api
      cors:
        origins:
          - https://portal.example.com
        credentials: true
    backend:
      service:
        name: api
        port: 8080

Runnable sample: examples/security/profiles.yaml.

Fields

FieldDescription
profilestrict, api, embeddable, or off
hstsauto (default), on, or off
frameinherit, deny, sameorigin, or off
content_type_optionstrue / false (nosniff)
referrer_policyHeader value; off disables
cspCSP policy string; off disables
cors.enabledExplicit on/off
cors.originsAllowed origins (required when CORS is enabled)
cors.methodsDefault: GET, POST, PUT, PATCH, DELETE, OPTIONS
cors.headersDefault: Authorization, Content-Type, Accept, X-Requested-With
cors.credentialsAccess-Control-Allow-Credentials
cors.max_agePreflight cache seconds (default 86400)

Precedence

  • Security headers apply on service, handler, redirect, WAF block, rate-limit, and error responses for matched routes.
  • backend.service.response.headers and handler headers are applied first; security headers are added unless the same key was already set.
  • Unmatched routes (404) use the global security: profile only.

Admin console

Edit global 安全 in the config modules panel; Host / Path overrides in the rule editor 安全 sidebar, or set rules[].security / paths[].security in YAML mode.

See also Configuration reference and Rewriting for manual response.headers.

Released under the MIT License.