nginx 内部调整:当前端调用一个control时,该controll执行调整回nginx中,跳转到controll2,
这样浏览器只能看到一个第一个controll地址,controll可以作为controll2的代理,加一些权限的控制;
———–controller
@RestController
@RequestMapping(“/faAttachments”)
public class FAAttachmentController {
@Value(“${file.commonDownload.url}”)
private String fileCommonDownloadUrl;
@Value(“${file.commonDownload.factor}”)
private String fileCommonDownloadFactor;
/*
* 文件下载
*/
@GetMapping(“/{id}”)
public void download(@PathVariable(“id”) String id, HttpServletRequest request, HttpServletResponse response)
throws RestError {
//各个业务权限判断
//验证************begin
//验证************end
//公共下载模块
response.setStatus(307);
long time = System.currentTimeMillis();
String factor = this.fileCommonDownloadFactor;
String sha1 = SHA1Util.getSha1(id+time+factor);
//response.setHeader(“Location”, “http://127.0.0.1:5881/portal/commonDownload/unPermission/”+id+”?time=”+time+”&sha1=”+sha1);
response.setHeader(“Location”, this.fileCommonDownloadUrl+”/”+id+”?time=”+time+”&sha1=”+sha1);
}
}
——nginx配置
location /portal/test {
access_log logs/portal.access.log upstreamlog;
proxy_pass http://tomcat/portal/test;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass_request_headers on;
proxy_intercept_errors on;
error_page 307 = @handle_redirect;
}
location @handle_redirect {
resolver 127.0.0.1;
set $saved_redirect_location ‘$upstream_http_location’;
proxy_pass $saved_redirect_location;
}
@GetMapping
public void redirect(HttpServletResponse response) throws IOException{
response.setStatus(307);
response.setHeader(“Location”, “http://127.0.0.1:8888/portal/verifyCode”);
}