2011-12-30 9 views
7

私はsqliteを使用してUbuntuで開発モードでrails 3.1を実行しています。レールサーバーはポート3000で動作しており、nginxはproxy_passポート80と443をポート3000に設定しています。config.force_ssl = trueをApplication.rbに入れ、レールサーバーを再起動すると、次のようなエラーが表示されます。Rails 3.1のSSL:config.force_ssl = trueが開発モードで動作していない

config.force_ssl = falseに戻して、レールサーバーを再起動すると、エラーが発生します。[2011-12-30 09:48:02] ERROR bad URI 9W\x0Fe���h=9��ݔ|�#��)�/6\x00\x00H\x00��'。レールコンソールに設置してください。ブラウザのキャッシュをクリアすると、これがなくなり、すべて正常に戻ります。しかし、どうすればforce_ssl = trueを動作させることができますか?ここで

は私Application.rbの一部です:

module Regi 
     class Application < Rails::Application 
     # Settings in config/environments/* take precedence over those specified here. 
     # Application configuration should go into files in config/initializers 
     # -- all .rb files in that directory are automatically loaded. 
     config.generators do |g| 
      g.template_engine :haml 
     end 
     config.force_ssl = true 
     end 
    end   

そして、ここで私は/ etc/nginxの/サイト対応/デフォルト:私は正確に同じエラーに遭遇した

server { 
    #listen 80; ## listen for ipv4; this line is default and implied 
    #listen [::]:80 default ipv6only=on; ## listen for ipv6 

    root /usr/share/nginx/www; 
    index index.html index.htm; 

    # Make site accessible from http://localhost/ 
    server_name localhost; 

    location/{ 
      # First attempt to serve request as file, then 
      # as directory, then fall back to index.html 
      proxy_pass  http://localhost:3000; 
      try_files $uri $uri/ /index.html; 
    } 


    #error_page 404 /404.html; 

    # redirect server error pages to the static page /50x.html 
    # 
    #error_page 500 502 503 504 /50x.html; 
    #location = /50x.html { 
    #  root /usr/share/nginx/www; 
    #} 

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    #location ~ \.php$ { 
    #  fastcgi_split_path_info ^(.+\.php)(/.+)$; 
    #  # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini 
    # 
    #  fastcgi_pass 127.0.0.1:9000; 
    #  fastcgi_index index.php; 
    #  include fastcgi_params; 
    #} 

    # deny access to .htaccess files, if Apache's document root 
    # concurs with nginx's one 
    # 
    #location ~ /\.ht { 
    #  deny all; 
    #} 
} 

# HTTPS server 
server { 
    listen  443; 
    server_name localhost; 

    #charset koi8-r; 

    #access_log logs/host.access.log main; 
    ssl on; 
    ssl_certificate /usr/local/conf/ssl_keys/server.crt; 
    ssl_certificate_key /usr/local/conf/ssl_keys/server.key; 

    location/{ 
     proxy_pass  http://localhost:3000; 
     proxy_set_header X-Real-IP $remote_addr; 
     # root html; 
     # index index.html index.htm; 
    } 

    #error_page 404    /404.html; 

    # redirect server error pages to the static page /50x.html 
    # 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root html; 
    } 
} 

答えて

2

メッセージは、私がnginx ssl serverを設定するときです。私はssl crtとkey.Andを持っていなかったので、あなたのnginxの設定ファイルで、私は気付いたことがありますcrtとkey.Soあなたは確信しています? わからない場合は、次のリンクをクリックしてself_assigned crtを作成してみてください。 http://devcenter.heroku.com/articles/ssl-certificate-self

p.s.私は小さなコメントとしてこの答えを追加したいが、私はこの許可を持っていないようだ。

関連する問題