We hide the services behind an AWS Security Group. But, we can use some trusty SSH action to forward localhost ports to those on the Solr server.
zsh and bash handle string splitting differently, so be sure to choose correctly for your shell.
For zsh:
SOLR_PORTS=(8080 9292 2812)for bash:
SOLR_PORTS="8080 9292 2812"for both shells
function portforward() {
SERVER=$1
for port in $SOLR_PORTS
do
echo "forwarding $port"
ssh -l ubuntu $SERVER -p 22 -N -f -C -L $port":localhost:"$port
done
}
function portforwardend() {
for port in $SOLR_PORTS
do
spec="\-L $port"":localhost:"$port
echo "unforwarding $spec"
ps aux | grep $spec | grep -v grep | awk '{print $2}' | xargs kill
done
}