Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Headers in Docker Kong #693

Closed
venkin304 opened this issue Dec 29, 2023 · 1 comment
Closed

Add Headers in Docker Kong #693

venkin304 opened this issue Dec 29, 2023 · 1 comment
Labels

Comments

@venkin304
Copy link

venkin304 commented Dec 29, 2023

I am trying to add HSTS header in the Kong docker-compose.yml file as env variable:
KONG_NGINX_PROXY_ADD_HEADER: 'Strict-Transport-Security: max-age=31536000'.

But I am getting CORS issue after adding this header. guess this setting is overriding 'Access-Control-Allow-Origin *'.

How can I add multiple headers in my docker-compose.yml file ?

Or is there a better way to add these headers in my dockerised Kong ?

@gszr
Copy link
Member

gszr commented Oct 23, 2024

Hey @venkin304

What you intend to do is

KONG_NGINX_PROXY_ADD_HEADER: "Strict-Transport-Security max-age=31536000"

From Nginx docs:

NGINX configuration blocks inherit add_header directives from their enclosing blocks, so you just need to place the add_header directive in the top‑level server block. There’s one important exception: if a block includes an add_header directive itself, it does not inherit headers from enclosing blocks, and you need to redeclare all add_header directives:

If you need to add more headers in a more Kong native way, I would recommend checking the post-function plugin for example -- see the docs here https://docs.konghq.com/hub/kong-inc/post-function.

@gszr gszr closed this as completed Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants