How to use a SRV record to point to port other than 80

2.2k Views Asked by At

I have this Route 53 record in the AWS console:

Type: SRV - Service Locator

And the value is:

1 10 4000 ec2-54-xx-xx-131.us-west-2.compute.amazonaws.com

so I was hoping that if I hit:

monitoring.x.teros.io

that it would reach:

ec2-54-xx-xx-131.us-west-2.compute.amazonaws.com:4000

but I am getting:

ERR_NAME_NOT_RESOLVED

anyone know how to use a SRV record to point to some endpoint that is not on port 80?

2

There are 2 best solutions below

2
Patrick Mevzek On

The 4000 in the SRV data of 1 10 4000 ec2-54-xx-xx-131.us-west-2.compute.amazonaws.com is the port. However, SRV records are only good if applications use them... and browsers do not.

So it seems you are in this case (your question is too vague and not really related to programming, but the error message you quote seems to come from a well known browser), and hence no SRV records will ever help you.

0
Evan Wies On

SRV records are not supported by many command line programs. To handle them, I made this simple tool srv-plz which resolves SRV records and allows injecting them into commands.

For your example monitoring.x.teros.io, you could fully resolve that and curl the ultimate ip:port with this command:

# print for debugging 
$ srv-plz -r -c monitoring.x.eros.io

# inject it into a curl command
$ srv-plz -r -c monitoring.x.eros.io -- curl http://%SRV%/health

You can template the SRV record output to fit the specific check you are testing. It is written in Go so available on many platforms.