Ruby on rails nginx http和https上的rails应用程序访问被拒绝
我正在使用Nginx,phusion\u在个人服务器上部署Rails应用程序。我已经创建了包含以下服务器块的站点配置文件。使用此配置,我的Ruby on rails nginx http和https上的rails应用程序访问被拒绝,ruby-on-rails,nginx,passenger,Ruby On Rails,Nginx,Passenger,我正在使用Nginx,phusion\u在个人服务器上部署Rails应用程序。我已经创建了包含以下服务器块的站点配置文件。使用此配置,我的http://192.168.1.121当https://192.168.1.121失败,出现禁止(拒绝访问)错误 production.rb具有force\u ssl:true 另外,若我用https条目删除服务器{}块,应用程序在http上运行得很好(当然我必须在production.rb中注释掉force_ssl:true)。如果从https访问同一个目
http://192.168.1.121
当https://192.168.1.121
失败,出现禁止(拒绝访问)错误
production.rb具有force\u ssl:true另外,若我用https条目删除服务器{}块,应用程序在http上运行得很好(当然我必须在production.rb中注释掉force_ssl:true)。如果从https访问同一个目录,我对拒绝访问错误感到非常困惑。
-nginx版本:nginx/1.6.2
-Rails 4.0
-Ruby 2.1.3
非常感谢您的帮助。尝试在与
端口80
配置相同的服务器
块上配置SSL
另外,它用于端口443
,而不是ssl on
指令
比如说:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# Use ssl parameter on the listening socket instead of the 'ssl on' directive
listen 443 ssl;
server_name 192.168.1.121;
# Rest of your ssl configuration here
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;
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 80 default_server;
listen [::]:80 default_server ipv6only=on;
# Use ssl parameter on the listening socket instead of the 'ssl on' directive
listen 443 ssl;
server_name 192.168.1.121;
# Rest of your ssl configuration here
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;
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;
}
}