NGINX头

Posted 一个学者

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NGINX头相关的知识,希望对你有一定的参考价值。

location / {
   
   #处理浏览器OPTIONS 预请求,默认返回200
   if ($request_method = ‘OPTIONS‘) {
    add_header ‘Access-Control-Allow-Credentials‘ true;
    add_header ‘Access-Control-Allow-Origin‘ "$http_origin";
    add_header ‘Access-Control-Allow-Methods‘ ‘GET, POST, OPTIONS‘;
    add_header ‘Access-Control-Allow-Headers‘ ‘DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range‘;
    add_header ‘Access-Control-Max-Age‘ 1728000;
    add_header ‘Content-Type‘ ‘application/json; charset=utf-8‘;
    add_header ‘Content-Length‘ 0;
    return 200;
   }
   
   proxy_pass http://tomcat ;
   #tomcat支持https 请求,须tomcat 更改相关配置
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
   proxy_set_header Host $http_host; 
   proxy_set_header X-Forwarded-Proto https; 
   proxy_redirect off; 
  
  
        }



以上是关于NGINX头的主要内容,如果未能解决你的问题,请参考以下文章

跟我学Nginx,nginx 如何处理请求?

nginx配置请求头防止点击劫持

[nginx]日志中记录自定义请求头

nginx开发头文件的包含顺序

编译安装nginx并修改版本头信息

nginx 定义:响应头和请求头