Deploying Ruby on Rails app on Nginx Puma localmachine - ruby-on-rails

Hi I am trying to deploy RoR app using puma as application server and Nginx. Iam following tutoril available here:
http://codeonhill.com/rails-capistrano-puma-nginx-on-vps/
Sorry Being a newbie in deployment, I want to ask whether we can deploy Rails app using Nginx as reverse proxy on local machine?
Secondly after wasting an entire day i could able to deploy it sucessfully
user#username-VirtualBox:~/Rails/rails-nginx-passenger-ubuntu/testapp$ bundle exec puma -b unix://tmp/testapp.sock
Puma starting in single mode...
* Version 3.8.2 (ruby 2.3.1-p112), codename: Sassy Salamander
* Min threads: 0, max threads: 16
* Environment: development
* Listening on unix://tmp/testapp.sock
* Starting control server on unix:///tmp/puma-status-1490292608378-29275
Use Ctrl-C to stop
And when i am trying to access this url iam getting google search result. How to access my application over there?

Related

Rails 6 are you trying to open an SSL connection to a non-SSL Puma?

I'm trying to set up Rails on AWS ECS with HTTPS access. When my ECS Service is deployed, these are the logs:
=> Rails 6.1.3.2 application starting in production
=> Booting Puma
* Listening on http://0.0.0.0:3000
* PID: 1
* Environment: production
* Max threads: 5
* Min threads: 5
* Puma version: 5.3.2 (ruby 3.0.1-p64) ("Sweetnighter")
Puma starting in single mode...
* Listening on http://0.0.0.0:3000
Use Ctrl-C to stop
2021-08-06 06:21:21 +0000 HTTP parse error, malformed request:
#<Puma::HttpParserError: Invalid HTTP format, parsing fails. Are you trying to open an SSL connection to a non-SSL Puma?>
I believe the health checks are hitting the container and failing. I'm not sure why this is happening. I already set config.force_ssl = true in my environments/production.rb. Any suggestions on what I am missing?
I'm using Rails 6.1.3.2 and ruby 3.0.1. Thanks!

AWS elastic beanstalk is not getting the environment variables

I'm trying to run a Rails 6 app on AWS Elastic Beanstalk, but I get from puma log the following (repeats every few seconds)
[21776] + Gemfile in context: /var/app/current/Gemfile
[21776] Early termination of worker
The version numbers:
Rails 6.0.3.3
puma 4.3.5
ElasticBeanstalk Ruby 2.7 running on 64bit Amazon Linux 2/3.1.1
ruby 2.7.1p83
The server is unresponsive from outside the instance, and there's nothing on log/production.log.
Running on a dev machine on production mode there's no errors, and the database is reachable (no migration failure).
Running on the AWS instance the command bundle exec puma -p 3000 -e production I get
Puma starting in single mode...
Version 4.3.5 (ruby 2.7.1-p83), codename: Mysterious Traveller
Min threads: 5, max threads: 5
Environment: production
Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
so there's no obvious error that may cause the worker to halt.
How can I find out what's causing the workers to fail?
Edit 1:
I ran Rails console on the instance and found that the environment variables are missing - e.g. the production database user/pass/host. Once I hardcoded them I could connect to the database.
I suspect the absence of other environment variables is making the app crash.
A user on AWS forum had the answer.
Setting in my Gemfile
gem "nio4r", "= 2.5.2"
fixed the issue.

Problem starting localhost server since Mac Os Catalina update

I haven't been coding for some time. I updated my Mac Os X version to Catalina (10.15.5) and upgraded my Ruby on Rails version.
It is now impossible for me to launch my local host and try and test my code. I tried several solutions explained here https://dba.stackexchange.com/questions/75214/postgresql-not-running-on-mac but none of them worked.
Here are the steps I do:
rails s
/Users/maximeroberti/.rvm/gems/ruby-2.4.3/gems/bootstrap-4.2.1/lib/bootstrap/version.rb:4: warning: previous definition of VERSION was here
/Users/maximeroberti/.rvm/gems/ruby-2.4.3/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:3: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA
/Users/maximeroberti/.rvm/gems/ruby-2.4.3/gems/bootstrap-4.2.1/lib/bootstrap/version.rb:5: warning: previous definition of BOOTSTRAP_SHA was here
=> Booting Puma
=> Rails 5.1.6 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.4.3-p205), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Going to localhost:3000/
The error I am facing is the following one when trying to connect to localhost:3000/
could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Thanks for your help!

cannot open url made by using rails server on cloud9IDE

I wanna open the url made by using rails server on cloud9IDE.So i try rails s -b $IP -p $PORT to run, and rails server is running, but when open url http://tcp://0.0.0.0:8080, the server cannot detected.
Could you help me?
$ rails s -b 0.0.0.0 -p 8080
=> Booting Puma
=> Rails 5.1.6 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.9.1 (ruby 2.4.1-p111), codename: Private Caller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:8080
Use Ctrl-C to stop
not detected img
Cloud9 is an IDE (Integrated Development Environment), so the way it works is a bit different than developing locally on your machine.
For example when run the server, it won't be possible to access it through localhost:3000. Instead Cloud9 will provide you with the link to see the running application, this link should normally pop-up when you run the server, but if not, then you can click on preview which you find in the upper menu (check the image below) and then preview running application

Why is rails server listing on tcp

I am working on a project which is an updated version of a new project. Using vagrant to load virtual environment and when i run
RAILS_ENV=development bundle exec rails s
The following is returned:
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
When i visit the browser I have tried localhost:3000 and 127.0.0.1:3000 but keep getting:
ERR_CONNECTION_REFUSED
On the previous version of this project on a different repository loaded it was accessible via these URL's. This project has been updated to Rails 5 but dont know why it is listening on TCP rather than HTTP. Any suggestions?
As it has been already suggested, make sure that the server is bounden to 0.0.0.0 so that all interfaces can access it.
You might try:
RAILS_ENV=development bundle exec rails s -b 0.0.0.0

Resources