http访问还没来得及设置就直接400
1
liuhaotian 2014-12-30 20:54:42 +08:00 12
listen 443 ssl;
if ($scheme!=https){rewrite xxx;} |
2
palytoxin 2014-12-30 21:04:42 +08:00
|
3
kenvix OP @liuhaotian 不行。。还是400
|
4
liuhaotian 2014-12-30 21:05:31 +08:00 12
@kenvix 难道你这个不是80端口?
|
5
kenvix OP @liuhaotian 自定义的web端口 你懂的
|
8
liuhaotian 2014-12-30 21:22:23 +08:00 via iPhone 11
@palytoxin 我觉得他的意思是非80端口要开https不能够这么跳转
|
9
kenvix OP @palytoxin 就是@liuhaotian 说的那样
|
10
Starduster 2014-12-30 21:33:32 +08:00
所以你没说清楚你改了什么地方啊。。。改了端口贴配置啊
|
11
kenvix OP @Starduster 我就是一个listen xxxx;这个端口开启ssl 要求http请求自动跳转...
server { listen 1234 ssl; if ($scheme!=https){rewrite...} } |
12
Starduster 2014-12-30 21:41:29 +08:00
@kenvix server {
listen 80; server_name XXX; rewrite ^(.*) https://$server_name:1234$1 permanent; } # HTTPS server # server { listen 1234 ssl spdy; server_name XXX; 实测可行,至于 SPDY 是我原来就开了的 |
13
Keyes 2014-12-30 21:47:23 +08:00 1
那個,實際真相是:
用error 497來做跳轉 首先 listen 80; listen 443; 然後配置497頁面 error_page 497 https://$host$request_uri; 最後使http來路的請求轉換到https(加入到主機定義行的最後位置): if ($server_port = 80) { return 497; } |
14
Keyes 2014-12-30 21:52:00 +08:00 1
WIKIPEDIA對於497的解釋(link: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes):
497 HTTP to HTTPS (Nginx) Nginx internal code used for the plain HTTP requests that are sent to HTTPS port to distinguish it from 4XX in a log and an error page redirection. |
15
superw 2014-12-31 00:00:00 +08:00
你是无名智者吧
|
16
BinbinWang 2014-12-31 00:13:46 +08:00
|