如何使用nginx配置phusion乘客以支持rails中的ssl?

时间:2015-11-02 20:31:55

标签: ruby-on-rails ssl nginx https passenger

我按照DigitalOcean的说明进行操作:https://www.digitalocean.com/community/tutorials/how-to-create-an-ssl-certificate-on-nginx-for-ubuntu-14-04

这是我的nginx.conf文件......似乎不起作用。

events {
    worker_connections  1024;
}

http {

  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 10m;
  keepalive_timeout 70;

  server {
    listen 80;
    listen 443;
    ssl on;

    server_name localhost;

    ssl_certificate /Users/sambit/Documents/Projects/SBOOKS/nginx.crt;
    ssl_certificate_key /Users/sambit/Documents/Projects/SBOOKS/nginx.key;

    # Extra protections
    ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;

    gzip            on;
    gzip_min_length 1000;
    gzip_proxied    expired no-cache no-store private auth;
    gzip_types      text/plain application/font-woff2 application/x-javascript text/css application/javascript text/javascript text/xml application/json application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype application/x-font-ttf application/xml font/eot font/opentype font/otf image/svg+xml;

    # Tell Nginx and Passenger where your app's 'public' directory is
    root /Users/sambit/Documents/Projects/SBOOKS/public;

    location ~ ^/(assets|images|javascripts|stylesheets|swfs|system)/ {
      gzip_static       on;
      expires           max;
      add_header        Cache-Control public;
      add_header        Last-Modified "";
      add_header        ETag "";
    }

    # Turn on Passenger
    passenger_enabled on;
    passenger_ruby /Users/sambit/.rvm/rubies/ruby-2.2.2/bin/ruby;
  }
}

我试图在Mac上测试这个..(el capitan)

我在chrome中遇到的错误是(ERR_SSL_PROTOCOL_ERROR)

  • 我还在7200号港口与领班一起运行我的rails应用程序

foreman start -p 7200

我的临时解决方案是使用乘客服务http请求并在同一台机器上生成美洲狮以处理https请求(均通过领班)。我知道这很黑,所以我正在寻找更好的基于乘客的解决方案。

1 个答案:

答案 0 :(得分:0)

此处为乘客作者。您还必须设置ssl on