通过nginx,ssl_error_rx_record_too_long提供ssl网页

时间:2015-04-22 16:05:10

标签: ruby-on-rails amazon-web-services nginx

请帮助我:此virtual.conf nginx配置文件中存在错误,这意味着在查看网站时,我收到错误ssl_error_rx_record_too_long而不是能够查看我的网站。我正在使用aws,nginx为一些rails应用程序提供服务 - 昨天工作正常,但我崩溃了我的整个服务器,我疯狂地试图在凌晨2点解决这个问题,准备在上午9:30进行生产。

ssl_certificate     /etc/ssl/star_my_site.pem;
ssl_certificate_key         /etc/ssl/star_my_site.key;


# ------------------
# rails app one
# ------------------

upstream my_app {
  server unix:///var/run/puma/my_app.sock;
}

server {
  listen      80;
#  server_name rails_app_one.my_site.com.au www.rails_app_one.my_site.com.au;
  server_name _ localhost;
  return      301 https://rails_app_one.my_site.com.au;
}

server {
  listen   443;
  server_name _ localhost;

  location / {
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto https;
     proxy_set_header Host $http_host;
     proxy_redirect off;
     proxy_pass http://my_app;
  }

  location ~ "^/assets/" {
    root /var/app/current/public;
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }
}

# ------------------
# rails app two
# ------------------

upstream rails_app_two_app {
  server unix:///var/run/puma/rails_app_two_app.sock;
}

server {
  listen      80;
  server_name rails_app_two.my_site.com.au www.rails_app_two.my_site.com.au;
  return      301 https://rails_app_two.my_site.com.au;
}

server {
  listen   443;
  server_name  rails_app_two.my_site.com.au;

  location / {
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto https;
     proxy_set_header Host $http_host;
     proxy_redirect off;
     proxy_pass http://rails_app_two_app;
  }

  location ~ "^/assets/" {
    root /var/app/rails_app_two.my_site.com.au/current/public;
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }
}

1 个答案:

答案 0 :(得分:0)

ssl_error_rx_record_too_long通常表示服务器在浏览器需要HTTPS内容时返回纯HTTP内容。 (您可以通过转到http://your.site:443并查看您的网站来验证这一点。)

您需要在nginx中启用SSL - 只需声明ssl_certificate是不够的。

listen 443;更改为listen 443 ssl;

(另外,我建议将ssl_certificate放在服务器块中,这样您就可以将不同的ssl证书与其他域一起使用。)

编辑:https://serverfault.com/questions/497430/error-code-ssl-error-rx-record-too-long几乎完全相同,希望您在早上9点发布之前找到它!