处理nginx 400“将纯HTTP请求发送到HTTPS端口".错误 [英] Dealing with nginx 400 "The plain HTTP request was sent to HTTPS port" error
问题描述
我正在旅客/nginx后面运行Sinatra应用程序.我正在尝试使其同时响应http和https调用.问题是,当在服务器块中同时定义了两者时,通常会响应https调用,但是http会产生400普通HTTP请求已发送到HTTPS端口"错误.这是用于静态页面,所以我猜Sinatra与这无关.有关如何解决此问题的任何想法?
I'm running a Sinatra app behind passenger/nginx. I'm trying to get it to respond to both http and https calls. The problem is, when both are defined in the server block https calls are responded to normally but http yields a 400 "The plain HTTP request was sent to HTTPS port" error. This is for a static page so I'm guessing Sinatra has nothing to do with this. Any ideas on how to fix this?
这是服务器块:
server {
listen 80;
listen 443 ssl;
server_name localhost;
root /home/myhome/app/public;
passenger_enabled on;
ssl on;
ssl_certificate /opt/nginx/ssl_keys/ssl.crt;
ssl_certificate_key /opt/nginx/ssl_keys/ssl.key;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
location /static {
root /home/myhome/app/public;
index index.html index.htm index.php;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 /500.html;
access_log /home/myhome/app/logs/access.log;
error_log /home/myhome/app/logs/error.log;
}
推荐答案
我遇到了类似的问题.它可以在一台服务器上运行,而不能在具有相同Nginx配置的另一台服务器上运行.在这里找到了Igor回答的解决方案 http://forum .nginx.org/read.php?2,1612,1627#msg-1627
I ran into a similar problem. It works on one server and does not on another server with same Nginx configuration. Found the the solution which is answered by Igor here http://forum.nginx.org/read.php?2,1612,1627#msg-1627
是的.或者,您可以将SSL/非SSL服务器合并在一台服务器中:
Yes. Or you may combine SSL/non-SSL servers in one server:
server {
listen 80;
listen 443 default ssl;
# ssl on - remember to comment this out
}
这篇关于处理nginx 400“将纯HTTP请求发送到HTTPS端口".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!