2

I have a ruby on rails application and I am trying to run it on the external ip of my google compute engine ubuntu 14.04 LTS VM.

I try rails server -e production

and the output is:

=> Booting Puma
=> Rails 4.2.4 application starting in production on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.14.0 starting...
* Min threads: 0, max threads: 16
* Environment: production
* Listening on tcp://localhost:3000

I do not want it to be at that location; I want it to be viewable from the external ip address of the server.

Part of the issue is that I do not know if this is a rails, a puma, or a google compute engine question.

Note: I can't see if it actually launching at localhost:3000 because the VM is just a terminal.

Rorschach
  • 3,684
  • 7
  • 33
  • 77
  • So localhost, in this instance, will represent your IP (unless you have a more complex setup); to bind it to a specific IP: `rails s -b 0.0.0.0`; you may find using Passenger to be more friendly. Also, take a look at DigitalOcean's guides for running a rails app on their servers. They have good articles, and it's provider-agnostic. – Josh Brody Jan 30 '16 at 11:00
  • @JoshBrody so, if it is returning that to the command line, then it should be viewable externally unless there is some local code preventing it? – Rorschach Jan 30 '16 at 11:05
  • In theory, yeah. It's probably a firewall (likely iptables). There's very little difference to a local and prod setup as far as publicly-accessible goes. To ensure that all is working well, you may want to `gem install localtunnel` and run it, just to make sure that it's not some weird firewall issue. – Josh Brody Jan 30 '16 at 11:07
  • you probably also need to configure the network settings of the VM. E.g. for kvm or VirtualBox, it won't work without a bit of configuration. – tillmo Jan 30 '16 at 16:24

1 Answers1

0

(I am assuming you are using nginx, if not, apt-get install nginx; service nginx start) If possible, show your nginx.conf (/etc/nginx/nginx.conf) and default.conf (/etc/nginx/sites-available/default.conf) Since you are using puma (I use it too) you should setup nginx conf file and set server upstream equal to puma's binding.

# /etc/nginx/sites-available/default.conf
upstream your_app {
     server 127.0.0.0.1:9292;
}

server {
     listen 80;
     server_name your_domain;
     root /usr/share/nginx/your_app/public;
     # or, if you are using capistrano
     root /usr/share/nginx/your_app/current/public;

     location / {
          proxy_pass http://your_app; # equal to upstream "name"
         ...
     }
     ....
 }

 # config/puma.rb
 [...]
 bind "tcp://127.0.0.1:9292"

And execute puma's server

$ bundle exec puma RAILS_ENV=production &

After doing this steps and if the application still doesn't work, output your /var/log/nginx/error.log, nginx.conf and default.conf

  • If I do not have a domain name, and am currently just using the ip, what should your_domain be? – Rorschach Feb 02 '16 at 16:43
  • I also cannot find my config/puma.rb file, I cannot find any file named puma.rb. Also, I just noticed this is my question from 3 days ago, I had just asked it again a bit differently today here: http://stackoverflow.com/questions/35152369/setting-up-a-rails-app-on-puma-rails-nginx-everything-is-running-but-nginx-se – Rorschach Feb 02 '16 at 16:58