nginx 反向代理设置中的proxy_redirect
来源:互联网 发布:上传淘宝的照片不清晰 编辑:程序博客网 时间:2024/06/09 21:06
Nginx做反向代理,如果在header设置了Host参数,同时如果有协议和二级目录有不一致的情况的时候,
LOG.debug("sendRedirect host in header " + req.getHeader("Host"));
response.sendRedirect("t2");
1,浏览器通过https + 域名请求后端 http应用
通过nginx的域名访问:https://www.xxx.com.cn/test/trd
默认配置的情况下:
server {
listen 443;
ssl on;
server_name www.xxx.com.cn;
location /test/ {
proxy_pass http://10.65.192.xx:8080/;
}
}
后端Java执行的情况为
LOG.debug("sendRedirect host in header " + req.getHeader("Host")); //10.65.192.xx:8080
response.sendRedirect("t2"); //http://10.65.192.xx:8080/t2
不需要设置proxy_redirect,nginx会将http://10.65.192.xx:8080/t2转成https://www.xxx.com.cn/test/t2
2,如果在header设置了Host参数:proxy_set_header Host $host;
LOG.debug("sendRedirect host in header " + req.getHeader("Host")); //www.xxx.com.cn
response.sendRedirect("t2"); //http://www.xxx.com.cn/t2
nginx需要配置proxy_redirect
server {
listen 443;
ssl on;
server_name www.xxx.com.cn;
location /test/ {
proxy_pass http://10.65.192.xx:8080/;
proxy_redirect http://$host/ https://$host:$server_port/test/;
}
当后端服务做302、301跳转的时候,需要用proxy_redirect将后端设置在response header中的Location做转换.
LOG.debug("sendRedirect host in header " + req.getHeader("Host"));
response.sendRedirect("t2");
1,浏览器通过https + 域名请求后端 http应用
通过nginx的域名访问:https://www.xxx.com.cn/test/trd
默认配置的情况下:
server {
listen 443;
ssl on;
server_name www.xxx.com.cn;
location /test/ {
proxy_pass http://10.65.192.xx:8080/;
}
}
后端Java执行的情况为
LOG.debug("sendRedirect host in header " + req.getHeader("Host")); //10.65.192.xx:8080
response.sendRedirect("t2"); //http://10.65.192.xx:8080/t2
不需要设置proxy_redirect,nginx会将http://10.65.192.xx:8080/t2转成https://www.xxx.com.cn/test/t2
2,如果在header设置了Host参数:proxy_set_header Host $host;
LOG.debug("sendRedirect host in header " + req.getHeader("Host")); //www.xxx.com.cn
response.sendRedirect("t2"); //http://www.xxx.com.cn/t2
nginx需要配置proxy_redirect
server {
listen 443;
ssl on;
server_name www.xxx.com.cn;
location /test/ {
proxy_pass http://10.65.192.xx:8080/;
proxy_redirect http://$host/ https://$host:$server_port/test/;
}
}
3.proxy_redirect 可以支持正则表达式,可以设置多个 proxy_redirect
阅读全文
0 0
- nginx 反向代理设置中的proxy_redirect
- nginx做反向代理proxy_pass,proxy_redirect的使用
- Nginx 反向代理设置
- Nginx 反向代理设置
- Nginx反向代理设置
- nginx 反向代理设置
- Nginx设置反向代理
- nginx反向代理设置
- 设置nginx反向代理
- nginx反向代理设置
- Nginx反向代理设置总结
- 关于nginx参数proxy_redirect的设置
- nginx 反向代理 端口设置问题
- Nginx反向代理Nginx
- Nginx反向代理Nginx
- Resin多端口设置以及Nginx反向代理设置(转)
- nginx proxy_redirect 的用法
- Nginx的proxy_redirect作用
- js基础(一)——数据类型
- git安装
- L1-034. 点赞
- Kickstart Round G 2017 Problem A. Huge Numbers
- 闭包
- nginx 反向代理设置中的proxy_redirect
- 自定义命名的元组collections.namedtuple
- 异常捕获
- VPN网络 私有网络(VPC)
- UVa10084
- mysql 触发器使用及详解
- angularjs之增删改查2
- 这是增删改查的表格
- angular表格添加+查找+修改