Toggle navigation
主页
文章
ChatGPT
在线编程
pygame-ide-online
关于
登录
注册
关注
私信
兜兜
文章
206
评论
12
点赞
98
原创 180
翻译 4
转载 22
文章
关注
粉丝
收藏
个人分类:
默认 (10)
数据库 (10)
网络 (0)
反向代理 (0)
容器 (9)
python (3)
爬虫 (2)
邮件服务器 (6)
C/C++ (1)
SOCKS4/SOCKS5 (0)
JavaScript/JQuery (0)
防火墙/VPN (2)
负载均衡/高可用 (9)
存储 (2)
虚拟机 (0)
分布式 (1)
NOSQL (0)
脚本 (1)
web服务器 (2)
安全 (3)
Linux/Unix (0)
ELK (1)
大数据 (5)
kubernets (19)
prometheus (1)
原创
阿里云SLB+nginx+tomcat HTTPS配置
兜兜
2018-08-09 15:07:32
2020-03-08 18:41:51
nginx
https
X-Forwarded-Proto
scheme
#### **nginx+tomcat** nginx配置: ```bash proxy_set_header Host $host; proxy_set_header Cookie $http_cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:8181; ``` tomcat配置: ```xml <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For" protocolHeader="X-Forwarded-Proto" internalProxies="172\.16.\d{1,3}\.\d{1,3}" #注意坑:如果使用tomcat7,并且内网ip是172网段需要加上internalProxies, 官网解释:http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/valves/RemoteIpValve.html protocolHeaderHttpsValue="https"/> ``` internalProxies参考:http://blog.inford.net/doc/171 #### **阿里云SLB+nginx+tomcat** 阿里云SLB配置:  nginx配置: ```bash proxy_set_header Host $host; proxy_set_header Cookie $http_cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; #http_x_forwarded_proto参数为SLB传过来的参数 proxy_pass http://127.0.0.1:8181; ``` tomcat配置: ```xml <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For" protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/> ``` #### 上面的配置,一般的访问没有问题,当页面发生302重定向会请求http的问题,出现 requested an insecure XMLHttpRequest nginx配置(nginx+tomcat) ```bash proxy_redirect http:// $scheme://; #302重定向请求的http协议转发到$scheme ``` nginx配置(阿里云SLB+nginx+tomcat) ```bash proxy_redirect http:// $http_x_forwarded_proto://; #302重定向请求的http协议转发到$http_x_forwarded_proto ```
阅读 2682
评论 0
收藏 0
阅读 2682
评论 0
收藏 0
个人信息
账号 : admin
昵称 : 兜兜
文章 : 206 篇
关注 :
勒布朗陈佩
...
斯2
|
海婧忆豚
|
大王山
|
不想差那么
...
一点
|
admin
...
istrator
|
EllJu
...
rb
|
shaji
...
ashenhua
个人网站 :
https://ynotes.cn/blog/user_zone/1
注册时间 : 2018-06-03
热门文章
xvfb+NoVNC实现web运行pygame
邮件服务器之postfix+dovecot+postfixadmin+TLS(一)
k8s部署rook-ceph集群
邮件服务器之日志分析(五)
xterm.js+django-channels实现docker的远程终端
docker-compose编排本博客django+mysql+nginx+uwsgi
CentOS7搭建LVS负载均衡器
H3C-S5130交换机常用操作
最近来访
18753
...
110861
转转
fred_
...
zheng2
不想差那么
...
一点
shaji
...
ashenhua
32325
...
23532
海婧忆豚
大王山