我刚刚使用Rubber& amp;在我的Rails应用程序上安装了SSL证书。 Capistrano要部署。现在,我的应用程序没有显示任何样式,图像很大,javascript也不再工作。
此应用程序以前部署在AWS中,并且只能使用HTTP,因此我对Rubber部署配置文件进行了更改并运行cap deploy
,现在结果就是这样。
以下是我修改的文件:
橡胶/角色/ nginx的/ unicorn_nginx.conf
<%
@path = "/etc/nginx/rubber/unicorn_nginx.conf"
%>
upstream unicorn_server {
# This is the socket we configured in unicorn.rb
server unix:/var/run/unicorn.sock
fail_timeout=0;
}
server {
listen 80;
<% if Rubber.env == 'production' %>
# SSL
listen 443 ssl;
ssl_certificate /etc/ssl/mycert.crt;
ssl_certificate_key /etc/ssl/private/server.key;
<% end %>
<% if Rubber.env == 'staging' %>
# SSL Cap
listen 443 ssl;
ssl_certificate /etc/ssl/mycert.crt;
ssl_certificate_key /etc/ssl/server.key;
<% end %>
client_max_body_size 4G;
server_name <%= [ rubber_env.domain, rubber_env.web_aliases ].flatten.compact.join(" ") %>;
keepalive_timeout 5;
# Location of our static files
root <%= Rubber.root + "/public" %>;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
<% if Rubber.env == 'production' || Rubber.env == 'staging' %>
proxy_set_header X-Forwarded-Proto https;
<% end %>
proxy_redirect off;
# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
proxy_pass http://unicorn_server;
break;
}
}
# this rewrites all the requests to the maintenance.html
# page if it exists in the doc root. This is for capistrano's
# disable web task
if (-f $document_root/system/maintenance.html)
{
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
error_page 500 502 503 504 /500.html;
location = /500.html
{
root <%= Rubber.root + "/public" %>;
}
error_page 404 /404.html;
location = /404.html
{
root <%= Rubber.root + "/public" %>;
}
}
&#13;
配置/环境/ staging.rb
Rails.application.configure do
config.host = "dev.server.com"
config.action_mailer.default_url_options = { host: config.host }
Rails.application.routes.default_url_options = { host: config.host }
ActionMailer::Base.smtp_settings = {
user_name: 'xxxxxxx',
password: 'xxxxxxxx',
domain: config.host,
address: 'smtp.sendgrid.net',
port: 587,
authentication: :plain,
enable_starttls_auto: true
}
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.force_ssl = true
config.log_level = :info
config.asset_host = "http://#{ENV['FOG_DIRECTORY']}.s3-us-west-2.amazonaws.com"
config.action_controller.asset_host = config.asset_host
config.action_mailer.asset_host = config.asset_host
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
end
&#13;
答案 0 :(得分:1)
CDN通常会允许任一协议。如果您使用http协议,https将起作用,以防在开发或登台服务器中出现。
反之则不起作用。
将其切换为使用“https”
config.asset_host = "http://#{ENV['FOG_DIRECTORY']}.s3-us-west-2.amazonaws.com"