Nginx出现The plain HTTP request was sent to HTTPS port问题解决方法
2015-04-15 09:53
1451 查看
今天在配置Nginx+SSL的时候出现如题的错误,后来与度娘一番云雨之后找到一个解决方法,挺有用,随手转之。
一般在vhost的配置中会有php解析的一段,如:
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_index index.php;
include fcgi.conf;
}
解释:
很多人认为使用 fastcgi_param HTTPS on;
这样是没错,不过强迫使用这个参数,不太有效!
最好的答案就是 fastcgi_param HTTPS $https if_not_empty; (参考下面 nginx 官方的链接),有 https 协议时才自动使用 https on,否则忽略 fastcgi_param HTTPS 这个参数。
内嵌的变量:
$https – 如果链接是 SSL 就返回 “ON”,否则返回空字符串。
if_not_empty; – 当参数有值时才传递到服务器
注意:这个方法只适合 Nginx 1.1.11 之后的版本
参考:
stackoverflow/nginx#1/nginx#2
您可能感兴趣的文章:
相关文章推荐
- Nginx:The plain HTTP request was sent to HTTPS port解决办法
- nginx: 400 Bad Request | The plain HTTP request was sent to HTTPS port
- nginx: 400 Bad Request | The plain HTTP request was sent to HTTPS port
- mysql 连接出现The last packet sent successfully to the server was 0 milliseconds ago.问题解决
- 解决 spring mvc3.1下post json出现HTTP Status 400 The request sent by the client was syntactically incorrect
- 解决SpringMVC入参出现The request sent by the client was syntactically incorrect请求语法错误方法
- https使用HttpWebRequest出现错误:System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.的解决方法
- 解决出现The FastCGI Handler was unable to process the request: 258 (0x80070102)的问题 等问题
- 解决出现The FastCGI Handler was unable to process the request:258(0x80070102)的问题
- 解决 spring mvc3.1下post json出现HTTP Status 400 The request sent by the client was syntactically incorrect
- 出现“unrecognized selector sent to instance”问题原因之一及解决方法。
- Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
- Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
- Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
- Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
- Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
- Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
- Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
- Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
- PHP配置的严重问题,终于解决了,The FastCGI Handler was unable to process the request.