Eth3rnit3
7/7/2019 - 8:38 PM

Rails + React build + Active Storage assets

  • Install passenger
  • Install nginx
  • Install nginx-passenger
  • Configure nginx-passenger for ruby path

Nginx conf

/etc/nginx/site-available/domain.com

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}
server {
  listen 80 default_server;

  root /home/deploy/www/sublime/current/public;

  # Add index.php to the list if you are using PHP
  index index.html;
  server_name 51.91.25.18;
  access_log /home/deploy/www/sublime/logs/access.log;
  error_log /home/deploy/www/sublime/logs/errors.log;
  server_name localhost;
  passenger_enabled on;
  passenger_app_env production;

location ~* ^.+\.(jpeg|gif|png|jpg|webp) {
            proxy_pass http://127.0.0.1:3000;
            proxy_http_version 1.1;
  }
location /sidekiq {
            proxy_pass http://127.0.0.1:3000;
            proxy_http_version 1.1;
  }
  location /api {
            # Insert your public app path
            proxy_pass http://127.0.0.1:3000;
            proxy_http_version 1.1;
            proxy_set_header Host $http_host;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_buffering off;
  }
  location / {
              # First attempt to serve request as file, then
              # as directory, then fall back to displaying a 404.
              try_files $uri /index.html;
  }
}