Deploying rails app on aws

Hmm, I got a couple of questions and I’m not sure if I am on the right path.

I registered a domain name with google, and also added a cloudflare account (with the google domain pointing to the cloudflare name servers).

On my AWS EC2 instance, i installed git and pulled my code from github, it was working great with an ip address ( I think using elastic ip on AWS helped).

Anyways, I had someone try to give me a hand with ngix and it was working, but the config went missing. lol. I had 404 errors and too many redirect errors.

I’m attempting to fix that. I’ve also added Phusion rackware, but confused to what that actually does.

So, do I just need to get ngix configured correctly for this all to work?

Thanks, Joe

Make sure you are using systemd to start puma automatically when the instance reboots, and restart it when it crashes. Here’s how to do this, from puma DOCS: File: Systemd — Puma-5.6.4

And here’s what I use in production (you need gem "sd_notify" in your Gemfile for it to work):

[Unit]
Description=Puma HTTP Server
After=syslog.target network.target

[Service]
Type=notify
WatchdogSec=10
User=app
WorkingDirectory=/home/app/production
SyslogIdentifier=puma_production

ExecStart=/home/app/.rbenv/shims/bundle exec puma -C /home/app/production/config/puma.rb -p 3000
Restart=always

[Install]
WantedBy=multi-user.target

I googled for “Phusion rackware” but couldn’t find it. Would you mind posting a link so I can check?

EDIT: BTW, this probably should be on rubyonrails-talk, not core.

hi, here it is.

You said it was working, but then stopped working. Was that after you added Phusion? If this is a standard Rails app, you already had puma as an application server, and adding phusion (also an application server) is unecessary and might have caused nginx to redirect requests to it instead of puma.

yes i guess that might be the problem. The guy I trusted added phusion, but did not disable puma. If they essentially do the same thing, i can remove one of them. that might have been the reason i was getting all those re-directed.

I’d say stick to Puma. It’s the recommended Rails gem so it will be easier to get support for it in forums, slack groups, etc.

ok, i got it working, not sure how.

I came across posting in stack overflow and it said to change the ssl config from standard to strict. That seems to have done it, i purged the cache on cloudflare too.
I also kind of reinstalled my certbot ssl certificate.

hopefully this will continue to work, now i got to fix other things like moving elasticsearch and getting my omniauth authentications working…

https://groupmerch.ca

not bad for a first time rails project.

1 Like

in case that can help. I use the phusion passenger docker image, that I build locally, and I push to beanstalk environment for deployment. domain name is attached to load balancer via AWS route53.

Nice!

My web app is working now. Just got some help with file ( image) uploads to an s3 bucket. I’ve got another server running elasticsearch. I changed my initializer to point to the new server, but it seems to still be connected to the elasticsearch addon on heroku. I’ve also have to fix omniauth on Facebook and Google.