'bind rails app on the IP provided by the host with 3000 port
I am running the rails app on VPS server provided by my host.
I need to run the same local app to the IP provided by them.
For eg myip:3000
Is it possible to do this, the IP provided by the host is a public/global IP.
How can I do this? Sorry for the dumb question.
Solution 1:[1]
After the release of Rails 4.2
the you cannot access the development mode rails server from another computer/virtual machine (remote access). So you need to bind the server to the ip
. You can do it by:
rails s -b 0.0.0.0
0.0.0.0 (means listen on all interfaces)
If you want to do it permanently you can do it by modifying the config/boot.rb
like this:
require 'rubygems'
require 'rails/commands/server'
module Rails
class Server
alias :default_options_bk :default_options
def default_options
default_options_bk.merge!(Host: '0.0.0.0')
end
end
end
Source: https://fullstacknotes.com/make-rails-4-2-listen-to-all-interface/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | software_writer |