The Golden Spot

I hope this helps someone who is learning about Linux and web application programming with Python, Django, and Javascript.

Sunday, October 05, 2014

SSH tunneling for SparkUI

When starting a Spark session you can visit the status page on port 4040 by default. For instance when you start the pyspark program you'll see:

14/10/06 05:22:03 INFO Utils: Successfully started service 'SparkUI' on port 4040.

I don't want to allow public access to this page so I'll use SSH to forward the port. I have port 8125 open for tcp connections on my gcloud instance. First, on the gcloud instance, forward the Spark service's port 4040 to port 8125, which is open to the Internet; while logged in to the gcloud instance run:

 ssh -4 -f localhost -L 8125:localhost:4040 -N

Next, on your laptop you'll want to forward the gcloud Internet available opened port at 8125 to a port like 2200 so that we can visit the page locally. On your laptop run:

ssh -N -L 2200:localhost:8125 10.10.10.10

replace '10.10.10.10' with the Internet facing IP of your gcloud instance.

Now visit http://localhost:2200 and the service that is running on your gcloud instance on port 4040 is first forwarded to 8125 on that host, and then forwarded to port 2200 locally. 


References: