Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

LWP - test website at multiple IPs

by mp (Deacon)
on Aug 10, 2005 at 19:19 UTC ( #482727=perlquestion: print w/replies, xml ) Need Help??

mp has asked for the wisdom of the Perl Monks concerning the following question:

In order to implement a DNS-based failover scheme, I need a way to fetch a web page from a server whose IP address is not listed in an A-record for the domain name (the backup server).

I have tried a number of approaches using LWP, including Direct a LWP connection to a different host, but have not found any that work reliably.

Can anyone show how to do this?

I would think that I should be able to use the IP address in the URL (http://1.2.3.4/) and force a Host header in a LWP request somehow, but after looking at the LWP documentation and trying several different approach, I've not come up with anything that works. Any help will be greatly appreciated.

Replies are listed 'Best First'.
Re: LWP - test website at multiple IPs
by Bob9000 (Scribe) on Aug 10, 2005 at 19:52 UTC

    I would think that I should be able to use the IP address in the URL (http://1.2.3.4/) and force a Host header in a LWP request somehow, but after looking at the LWP documentation and trying several different approach, I've not come up with anything that works.

    That was my first thought as well, and it seems to work just fine for me:

    $ua = new LWP::UserAgent; print $ua->get("http://1.2.3.4/", Host => "www.domain.com")->content;

      Thank you. This works perfectly. The request is made to IP=1.2.3.4, and the host header www.domain.com is sent in the request.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://482727]
Approved by Popcorn Dave
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-01-18 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (53 votes). Check out past polls.

    Notices?