【发布时间】:2014-12-10 07:22:05
【问题描述】:
我正在使用 Nginx phusion_passenger 在个人服务器上部署 Rails 应用程序。我有带有以下服务器块的站点配置文件。使用此配置,我的 http://192.168.1.121 服务无法工作,而 https://192.168.1.121 因禁止(拒绝访问)错误而失败。
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# Make site accessible from http://192.168.1.121/
server_name 192.168.1.121;
passenger_enabled on;
rails_env production;
root /home/deploy/www/myrailsapp/current/public;
index index.html index.htm;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 443;
server_name 192.168.1.121;
passenger_enabled on;
rails_env production;
root /home/deploy/www/myrailsapp/current/public;
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
error_page 500 502 503 504 /50x.html;
location / {
try_files $uri $uri/ =404;
}
}
production.rb 有 force_ssl: true
此外,如果我删除带有 https 条目的 server {} 块,应用程序在 http 上工作得很好(当然我必须从 production.rb 中注释掉 force_ssl: true )。如果从 https 访问同一目录,我对拒绝访问错误感到非常困惑。
- nginx版本:nginx/1.6.2
- Rails 4.0
- 红宝石 2.1.3
任何帮助表示赞赏。
【问题讨论】:
标签: ruby-on-rails nginx passenger