0

Let's say I have a running nginx instance with several server blocks (on a linux server), and that I would like to send an extra HTTP header like Permissions-Policy: interest-cohort=() on all responses because I agree with Google's FLOC being a bad idea.

I know this can be done on a per-server block basis (by editing each of my /etc/nginx/sites-available/* files one by one) by adding something like

server {
    location / {
        add_header Permissions-Policy interest-cohort=();
        # ...other stuff
    }
    # ...other stuff
}

Is it possible to configure this extra HTTP header for all locations of all server blocks at once? If so, how?

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
IvanSanchez
  • 103
  • 1
  • 4

1 Answers1

2

According to the nginx docs, yes:

Syntax: add_header name value [always];
Default: —
Context: http, server, location, if in location

Adds the specified field to a response header provided that the response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304, 307 (1.1.16, 1.0.13), or 308 (1.13.0). Parameter value can contain variables.

There could be several add_header directives. These directives are inherited from the previous configuration level if and only if there are no add_header directives defined on the current level.

If the always parameter is specified (1.7.5), the header field will be added regardless of the response code.

by putting in http it will apply to all server blocks.

Paul
  • 3,037
  • 6
  • 27
  • 40