我正在旅客/ nginx后面运行Sinatra应用程序。我正在尝试使其同时响应http和https调用。问题是,当在服务器块中同时定义了两者时,通常会响应https调用,但是http会产生400“普通HTTP请求已发送到HTTPS端口”错误。这是用于静态页面的,所以我猜测Sinatra与这无关。有想法该怎么解决这个吗?
这是服务器块:
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;
}
ssl on;告诉NGINX 通过SSL 服务器任何内容。在您的末尾使用“ ssl”标志,listen 443;例如,listen 443 ssl;如果您的服务器同时传递http和https流量,并删除ssl on;指令。
                
my.example.com:443不起作用。改为改为https://my.example.com工作。很奇怪,Apache从来没有遇到过这个问题。