首页 > 其他 > 详细

nginx 定义:响应头和请求头

时间:2019-10-04 14:27:26      阅读:113      评论:0      收藏:0      [点我收藏+]

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 定义:响应头和请求头

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!