码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 定义:响应头和请求头

时间:2019-10-04 14:47:16      阅读:1563      评论:0      收藏:0      [点我收藏+]

标签:col   设置   style   nbsp   for   dom   div   encoding   span   

1) 响应头

add_header

例如:

        add_header Cache-Control no-cache;
        add_header Access-Control-Allow-Origin *;
        add_header X-Proxy-Cache $upstream_cache_status;

 要小心Nginx的add_header指令详解:

当当前层级中没有add_header指令才会继承父级设置。所以我的疑问就清晰了:location中有add_header,nginx.conf中的配置被丢弃了。

例如你在 location层添加了一个add_header 信息,在server 层也添加了一个add_header信息,

那么server 层的add_header会被丢弃,所以要小心添加

 

2) 请求头

proxy_set_header

例如:

    proxy_set_header Accept-Encoding "";
    proxy_set_header Host $http_host;
    proxy_cookie_domain $host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 

nginx 定义:响应头和请求头

标签:col   设置   style   nbsp   for   dom   div   encoding   span   

原文地址:https://www.cnblogs.com/faberbeta/p/nginx-configure002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!