The deployment was successful and everything is green. But when we try to access the application URL, it gives 502 Bad Gateway
error.
Checking for puma process with ps -aux | grep puma
doesn't return any process attached to puma server but pgrep
returns following.
$pgrep -fl puma
18009 su -s /bin/bash -c bundle exec puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb webapp
18031 ruby /opt/rubies/ruby-2.0.0-p598/bin/puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb
I had this issue after uploading my rails app, I found this line (auto generated) on secrets.yml (config > secrets.yml) :
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
so you have to add it as an environment variable to your environment.
In the environment dashboard go to Configuration > Software > Environment properties and add a new variable with name SECRET_KEY_BASE.
You can set any value but make sure it is a safe key. This resolved the issue for me, I hope it helps.
I have tried all possible combinations, as shown in every other forum/blog OR support sites of nginx/puma. Following is the status.
My question is,
Puma is not able to run even with default configurations, so it nginx is not able to talk to Puma and so the EC2 does not really make sense!
Please let us know, how we can resolve this issue, if you have any idea on this.
See this - https://forums.aws.amazon.com/thread.jspa?messageID=608148򔞔
Still no answers on this one, this is like our hands are cuffed and not able to change any configurations!
UPDATE
AWS is somehow stopping and starting PUMA, because i can see the process IDs changing when checking with
ps -ef|grep puma
. So, I started the puma to work on another port and tried to check if it runs or not.Started on another port, and then from another console accessing the URL using
wget http://127.0.0.1:3000
. It prints the following log.So, is it compulsory to use SSL? Because I think by default, it is not enabled.
I could not fix this problem. Also we supposed to use EC2 free instance only instead of BeanStalk.
We have now moved to Free EC2 instance with RDS and deployed the rails application using Capistrano with Nginx + Unicorn. Though it was not easy[1][2] but finally we got it working.