X-Frame-Options 标头未设置为 nginx

时间:2021-02-12 12:45:45

标签: nginx http-headers x-frame-options x-content-type-options

我的网站在 nginx 服务器上。我添加到/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

1 个答案:

答案 0 :(得分:0)

我们需要更多关于您的 nginx.conf 文件的信息,但您可以将此指令添加到您的 server 块中:

server {
    
    listen 80;
    server_name example.com;

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

    # ...
}

可能位于 /etc/nginx/sites-enabled/example.com/etc/nginx/conf.d/example.com.conf

http 中的 /etc/nginx/nginx.conf 块所示:

http {
    
    # ...

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