Jack Moore

Email: jack(at)jmoore53.com
Project Updates

Rails and NGINX

24 Aug 2019 » rails, credentials

Rails assets can be a bit of a challenge when compiled… The guides reccommend serving the assets from the NGINX server.

I am currently serving assets from the rails application to simplify deployments.

# config/environments/production.rb 
config.public_file_server.enabled = true

This is how the assets are supposed to be configured in the nginx configuration file for the rails webserver public file. I believe this method is difficult to configure with Docker unless the

upstream puma {
  server unix:///home/deploy/apps/appname/shared/tmp/sockets/appname-puma.sock;
}

server {
  listen 80 default_server deferred;
  # server_name example.com;

  root /home/deploy/apps/appname/current/public;
  access_log /home/deploy/apps/appname/current/log/nginx.access.log;
  error_log /home/deploy/apps/appname/current/log/nginx.error.log info;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  try_files $uri/index.html $uri @puma;
  location @puma {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    proxy_pass http://puma;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 10M;
  keepalive_timeout 10;
}
© Jack Moore - This site was last built Fri 30 Aug 2024 12:31:24 PM EDT