ITeye博客

java redirect https跳转http问题

langmnm · 2017-09-10 12:47 · nginx · 开源软件 · Markdown

一、前提 nginx: https tomcat:http java:springmvc

二、问题描述 通过https访问到nginx,通过nginx proxy_pass 到http的tomcat。 正常访问都正常,但是只要java redirect就跳转到http。

三、解决方案


            proxy_pass http://10.0.1.107:8080;
            proxy_set_header Host $host:$server_port;
            proxy_redirect http:// https://;

实现流程:根据nginx的不同执行阶段,来完成Location http到https。

  1. proxy_pass执行前,先设置了request head host 为https外网访问的域名+端口
  2. proxy_pass执行后,tomcat结果返回response
  3. proxy_redirect修改response中的location中的协议http为https外网访问的协议。

因为最近没有时间,就不排版了,调试这个问题已经浪费了不少时间。查了不少资料,这个算是准确的。我主要想记录一下nginx的执行阶段。

http://blog.csdn.net/lindev/article/details/23952395

四、java redirect 这个主要是通过访问tomcat的请求head项来决定的,默认是http协议,域名是通过读取host地址,默认host中不包括访问端口。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。