I am new to Ruby.
I am working with a script that deploys a HTTPServer using WEBrick.
When the script runs, it logs out :
check_1 | [2018-12-20 17:51:47] INFO WEBrick::HTTPServer#start: pid=1 port=4567
When I do a netstat
on the machine, I notice that the service is listening only on 127.0.0.1
$ netstat -tulpn
root@c4a20aa7bd8c:/opt/service# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:4567 0.0.0.0:* LISTEN 1/ruby1.9.3
I want to listen on all the IPs so that I can communicate with this service from another container.
How or what configs will be necessary ?
My script definition for the server is :
#!/usr/bin/ruby
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader' if development?
also_reload 'config.yml'
require "sinatra/config_file"
require 'mechanize'
require "json"
require 'open-uri'
require 'mongo'
require 'uri'
require 'addressable/uri'
require 'cgi'
include Mongo
require 'nokogiri'
set :server, 'webrick'
The answer you're looking for is in the Sinatra config docs: http://sinatrarb.com/configuration.html
Specifically the :bind
option. Example: set :bind, '0.0.0.0'