gimme dat ip

So there’s something I use quite often to get the public IP of the host I’m using:

  • curl icanhazip.com
  • curl checkip.amazonaws.com

And now, introducing the new and improved (unlikely), dbag.tech IP returning URL. It has bells, it has whistles, it can clean and buff your car.

DBAG Tech Get IP

The idea is the following:

  • Client sends HTTP GET request for /getip
  • NGINX Docker container matches request path, and sends to explicit location match that does a proxypass to another internal Docker container
  • Sinatra web app with the following code
set :bind, '0.0.0.0'

get '/' do
  "#{request.ip}"
end

Some additional updates to my NGINX container:

  • Enabled HTTP2 (https://www.nginx.com/blog/nginx-1-9-5/)
  • Enabled HSTS (https://www.nginx.com/blog/http-strict-transport-security-hsts-and-nginx/)
  • Updated restart command for container due to not using a load balancer (cleaned up one liner for easier reading)
for i in $(aws ecs list-tasks --cluster cluster | jq -r .taskArns[]);
  do
  GROUP=$(aws ecs describe-tasks --cluster cluster --tasks $i | jq -r .tasks[].group);
  if [ "$GROUP" = "service:website" ]; then
    aws ecs stop-task --cluster cluster --task $i;
  else
    continue;
  fi;
done
Ryan Gravlin's Picture

About Ryan Gravlin

Over 25 years experience as a system operator.

Miami, FL https://dbag.tech

Comments