Introduction
Use the following technique to diagnose website issues with curl when the current A record does not point to the IP address of the server that you need to test.
An alternative method to the one below is by using the --resolve option for curl. This can be found in the curl man page linked at the bottom of this guide if you are interested in that method.
Procedure
Use the following command:
curl -IL -H"Host: domain.tld" http://IP.ADDRESS.OF.SERVER/file.txt
Here is a breakdown of the command:
- -I The I option makes it so only the headers of the request are printed. This is useful for viewing the metadata of the request such as the HTTP status code.
- -L The L option allows curl to follow redirects
- -H The H option allows you to specify custom request headers. For every web request, the Host request header tells the web server what virtualhost should be served. Manually setting the Host header allows you to make the request to any IP address as opposed to the currently set A record of the domain
- And the last portion is the request address. In this portion we use the IP address of the server to ensure that the request goes to our desired server rather than the IP set in the A record for the domain.
- Note that file.txt is optional and represents additional parts of the URL that you specify.