1

I have a rails 4 application configured to use passenger and nginx. The application works as expected over HTTP, however when I use HTTPS the CSS and JS files are not served (although the images and text are).

My nginx config file is as follows:

server {
        listen       80;
        listen 443 ssl;
        server_name  divvyup.com.au;
        root /home/duroot/www/rails/DivvyUp/current/public;
        ssl_certificate      divvyup.com.au.chained.crt;
        ssl_certificate_key  divvyup.com.au.key;
        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers         HIGH:!aNULL:!MD5;
        passenger_enabled on;
        location /assets/ {
                gzip_static on;
                expires max;
                add_header Cache-Control public;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

My production.rb file contains:

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.precompile << /(^[^_\/]|\/[^_])[^\/]*$/
  config.assets.digest = true
  config.assets.version = '1.0'
  config.force_ssl = false

Any help would be great...

2
  • try: config.force_ssl = true Commented Nov 12, 2015 at 12:58
  • That simply forces the website to use ssl. The content is still displayed without the CSS and JS. Commented Nov 12, 2015 at 19:47

1 Answer 1

1

I found the answer to this.

I had set the asset_host directive to include http: forcing the assets to be served as HTTP.

Updating the directive as follows resolved the issue:

config.action_controller.asset_host = 'www.divvyup.com.au'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.