X-Frame-Options header doesnt set to nginx

2.6k views Asked by At

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

1

There are 1 answers

0
Pierre On BEST ANSWER

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/*;
}