Nginx反向代理设置header
特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过。如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处: http://www.cnblogs.com/mao2080/ 1、问题所在 在做前后端联调时,需要对不同的url增加header。 2、代码片段 2.1Nginx配置 1 server { 2 listen 80; 3 server_name test.com; 4 5 location /api/ { 6 proxy_pass http://localhost:8081/api/; 7 proxy_set_header tenant 1006; 8 } 9 10 location / { 11 root D:\web; 12 index index.html; 13 } 14 15 } 2.2Java接口 1 @RequestMapping(value = "/checkHeader", method = {RequestMethod.POST}, consumes = MediaType.APPLICATION_JSON_VALUE) 2 @ResponseBody 3 public String checkHeader(HttpServletRequest request) throws IOException {