各种 Google 找不到答案,无奈只好请教一下大家。
先交代一下背景:
- 网站使用阿里云 SLB 做负载均衡的,证书也配在 SLB。
- SLB 的 https 实际上转发的是 http443,正常的访问是可以的。但是今天输入一个已存在的目录是,少输入了「/」结尾,nginx 进行了补全,然后返回的 Location 是 http443,由于 SLB 的 http443 没做转发,就导致网站无法访问了。找了很多的方法,都没办法解决这个问题,有劳各位大大了。
现象重现:
$ curl -I https://test.com/abc
HTTP/1.1 301 Moved Permanently
Date: Tue, 11 Dec 2018 11:48:50 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: http://test.com:443/abc/
slb 配置
http[80] => http[80]
https[443] => http[443]
nginx 配置
server {
listen 80;
server_name test.com;
return 301 https://test.com$request_uri;
}
server {
listen 443 ssl;
server_name test.com;
ssl on;
ssl_certificate /etc/ssl/test.com.crt;
ssl_certificate_key /ect/ssl/test.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
index index.html;
root /data/web/test.com;
}