Warm tip: This article is reproduced from serverfault.com, please click

X-Frame-Options header doesnt set to nginx

发布于 2021-02-12 12:45:45

My site is on nginx server. Im add to the /etc/nginx/nginx.conf

add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;

The headers is not appear on the site:

The headers is not appear on the site

Questioner
Karina
Viewed
0
Pierre Arnissolle 2021-02-12 21:16:53

We need more about your nginx.conf file, but you can add this directives into your server block:

server {
    
    listen 80;
    server_name example.com;

    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;

    # ...
}

Maybe located at /etc/nginx/sites-enabled/example.com or /etc/nginx/conf.d/example.com.conf.

As indicated in the http block in /etc/nginx/nginx.conf:

http {
    
    # ...

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}