| CARVIEW |
Select Language
HTTP/2 200
cache-control: max-age=3600
content-encoding: gzip
content-type: text/html; charset=utf-8
etag: "c360d40ae28253cf1b52d73cd4f67301701186186004d5a82263d27401167822"
strict-transport-security: max-age=31556926; includeSubDomains; preload
accept-ranges: bytes
date: Mon, 26 Jan 2026 18:28:04 GMT
x-served-by: cache-bom-vanm7210082-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1769452085.734789,VS0,VE188
vary: x-fh-requested-host, accept-encoding
alt-svc: h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400
content-length: 3317
socat tips (Rails) Generate a new Rails project with railspg
Allow Public Access to a Remote Ruby-on-Rails Development App with Socat
A Ruby-on-Rails development app running under localhost on a remote server may be exposed to to public access as follows:
Start a Rails app on the remote server:
rails s
On the remote server execute the following socat  command:
socat TCP-LISTEN:8090,fork TCP:localhost:3000
Now the Rails application will be available publicly at:
yourserver.com:8090
For example, if the server is at tomgdow.com, the app will be available at www.johndow.com:8090.
Notes
Netcat may be used to check that all is well
netcat -z -v localhost 8090 » Connection to localhost 8090 port [tcp/*] succeeded!
Alternative method with ssh tunnel
After starting the Rails server, open an ssh tunnel on the remote server:
ssh -R 4000:localhost:3000 janedow@johndow.com -N
In a separate teminal window, use socat to open a port on the server to public access:
socat TCP-LISTEN:8090,fork,reuseaddr TCP-CONNECT:127.0.0.1:4000 &
As for the previous method, the Rails development app is available publicly at yourserver.com:8090.
Notes
janedow@johndow.com are the user credentials on the remote machine
Securely Access a Remote Ruby-on-Rails Development App with ssh
A Ruby-on-Rails development app running under localhost on a remote server may be securely accessed from a local machine as follows:
Start a Rails app on the remote server (port 3000)
rails s
On the local machine execute:
ssh -N -f -L localhost:4000:localhost:3000 janedow@johndow.com
The Rails application will now be accessible from a local machine at:
localhost:4000
Notes
A password will be required for ssh access to the remote machine
janedow@johndow.com are the user credentials on the remote machine
Other ssh Tips
Find the hostname of the remote machine
ssh -t janedow@johndow.com -- hostname
List the home directory of the remote machine
ssh -t janedow@johndow.com -- ls
Other Useful Commands
lsof -i # lsof: list open files lsof -wni tcp:3000 ps -aux | grep ruby # ps snapshot of current processes netstat -antlp |grep "LISTEN" | grep 'ruby'
Log for the Creation of a Simple Rails App
This Rails app was created on a Digital Ocean Droplet with Ubuntu as OS
Some preliminaries. (remote server command line)
uname -ro; rails -v; ruby -v; nodejs -v; lynx -version
» 3.13.0-57-generic GNU/Linux » Rails 4.2.5 » ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux] » v0.10.25 » Lynx Version 2.8.8pre.4 (04 Feb 2014)
The Rails project was created as follows
mkdir railsProjects && cd $_
rails new myrailsapp && cd $_
bundle install
rails s
# Check that all is well:
curl localhost:3000 | grep -i 'Welcome'
» <h1>:Welcome aboard</h1> # (abridged)
# Generate a scaffold
rails generate scaffold Product name:string description:text price:float
rake db:migrate
# Set the routes
sed -i "s/'welcome#index'/'products#index'/" config/routes.rb
sed -i 's/#\{1,2\}[[:space:]]\{0,10\}root/\ root/' config/routes.rb
# Open a remote port to public access
socat TCP-LISTEN:8090,fork TCP:localhost:3000
# Check that all is well
netcat -z -v localhost 8090
» Connection to localhost 8090 port [tcp/*] succeeded!
# On browser:
johndow.com:8090 # (ie server-name.com:port-number)
# From the browser, added some products
# The final result was something like the following:
Rails Development App on Remote Server Notes
Lynx, a text web browser, may be used instead of curl to check that all is well
Sed Commands
- The sed commands used to programatically change text in config/routes.rb are specific to Ubuntu,and may not work as expected on the Mac OS, as the GNU and BSD versions of sed behave differently
- The first command merely changes the default root 'welcome#index' to root 'products#index' in config/routes.rb
- The second command uncomments the line (removes the '#') containing the word root in config.rb.
- These changes may be easily made with any text editor or IDE, instead of using sed
Local access over ssh
- Instead of using socat to open a port to public access, the Rails app was securely accessed over ssh as follows:
# On server: rails s # On local machine: # (here a Windows 10 computer, using Powershell to execute ssh command. Putty will work equally well) ssh -N -f -L localhost:4000:localhost:3000 janedow@johndow.com # enter password # On local browser (here Firefox running on Windows 10): localhost:3000