[文章作者:张宴 本文版本:v1.0 最后修改:2008.12.15 转载请注明原文链接:http://blog.zyan.cc/post/389/]

  PHP获取远程网页内容有多种方式,例如用自带的file_get_contents、fopen等函数。
引用
<?php  
echo file_get_contents("http://blog.zyan.cc/abc.php");  
?>

  但是,在DNS轮询等负载均衡中,同一域名,可能对应多台服务器,多个IP。假设blog.zyan.cc被DNS解析到72.249.146.213、72.249.146.214、72.249.146.215三个IP,用户每次访问blog.zyan.cc,系统会根据负载均衡的相应算法访问其中的一台服务器。

  上周做一个视频项目时,就碰到这样一类需求:需要依次访问每台服务器上的一个PHP接口程序(假设为abc.php),查询这台服务器的传输状态。

  这时就不能直接用file_get_contents访问http://blog.zyan.cc/abc.php了,因为它可能一直重复访问某一台服务器。

  而采用依次访问http://72.249.146.213/abc.phphttp://72.249.146.214/abc.phphttp://72.249.146.215/abc.php的方法,在这三台服务器上的Web Server配有多个虚拟主机时,也是不行的。

  通过设置本地hosts也不行,因为hosts不能设置多个IP对应同一个域名。

  那就只有通过PHP和HTTP协议来实现:访问abc.php时,在header头中加上blog.zyan.cc域名。于是,我写了下面这个PHP函数:

Tags:



技术大类 » PHP/JS/Shell | 评论(59) | 引用(1) | 阅读(76975)
Hogan
2012-5-10 18:10
IssuesFinally fiscale, un sacco di uomini e donne non dovranno avere il commercialista per aiutarti a queste persone che utilizzano fiscale soprattutto perché può essere più realizzato per mezzo di suo posto Hogan di lavoro, ci sono occasioni in cui si può sicuramente trovare sul proprio volere risorse umane suggerimenti. Non importa se vi capita di essere interessati a problemi circa dono di prelievo denaro o forse avere una serie di suggerimenti fiscali, la loro spesso preferibile a chiedere nel caso in cui youre chiaro.
coach factory outlet Email Homepage
2012-5-17 11:53
Today, following half a century, mentor leather-bases coach factory outlet continues to be the delicate craft of leather-based master is accountable for,Would you like to meet more friends, or go with the times? If yes, coach factory online is opening welcome doors to you.in the market you definitely can find various colorways that are designed in as well as the high quality that applied in. For most of you would like to come. So just come to our coach factory outlet online store to choose one.
louis vuitton sale Email Homepage
2012-5-17 11:54
Louis Vuitton belt at louis vuitton sale is one kind of fashion accessory with high cost performance among the Louis Vuitton accessories.Offering quality LV products with favorable prices, louis vuitton outlet store is at your service. Hurry up, or you can not seize the chance.in fact, louis vuitton is one of the most famous fashion design master.he opened the fist suitcase shop called after his name.
coach outlet online Email Homepage
2012-5-17 11:54
I heard of coach outlet online through the advertisement when I was shopping. And now I often brow the webpage and buy Coach bags online.It is a symbol regarding position not to mention nature.Here I would like to launch a excellent bags pertaining to business men.Which may be coach outlet store.coach outlet has always been simple,durable style features to win consumers.The products are more flexible,with easy bleaching,wear characteristics,and simply use a damp cloth.
coach outlet, Email Homepage
2012-5-17 11:54
Remember the coach outlet provide coach bags which won't be deteriorated into its overall styles by any means. It will maintain its looks, colors, and uniqueness for long time.coach outlet store online has been voted by Hour Detroit magazine readers as the Best of Detroit in their 12th annual readers'poll.Lots of women like which usually amount normally include a coach outlet online ,it provides coziness to many girls that don't even think it is a great bushel of great interest directly to them.
xujie123
2012-5-21 11:28
Our online store offers you discounted Designer louis vuitton replica wallet at present. You could find them in desirable quality and price. If you don't mind high class louis vuitton uk, have a good time here.louis vuitton Store Online Handbags can also bring great accuracy as well as practical applicability and fashionable.Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.<br/>
xujie555
2012-5-21 13:55
coach factory outlet uses graceful accessories to match the classical logo of coach, which is the best combination of coach. The handmade coach products?can make you more charming and graceful.coach factory online provides people many coach goods. If you wish to snatch the coach handbag, then this best method is made for that you like for coach discount.coach factory outlet online is a fashion brand to ensure its quality. With designer coach shoulder bags, you will always attract people's attention. The bags will emphasize your personal style and taste.<br/>
xujie333
2012-5-21 15:18
coach outlet online Store guarantee that all the coach handbags offered are own high quality. In addition , all of them are sold at an unexpected low price.If you want to purchase, just visit their website.coach factory outlet is really sizzling kinds of shopping way for you. With the usage of the replica designer coach bags, you can surely be able to change your individual looks in a stunning manner.Coach bags on sale from the coach outlet are cheap or discount prices that you certainly will stand out from the crowd on your next camping trip!<br/>
Coach Outlet Online Email Homepage
2012-6-8 10:57
http://www.atcoachoutletsonline.net/ Coach Outlet Online
http://www.getcoachfactoryoutlet.org/ Coach Factory
http://www.louisvuittonhandbagsoutlet.org/ Louis Vuitton Handbags Outlet
http://www.saleincoachoutlets.com/ Coach Outlet
xnbo50qjnw6 Email Homepage
2012-6-9 13:29
请问!!怎么没人回贴子的吗??谢谢
Lyle Aiken
2012-7-14 10:32
These statement looks will definitely give away your Human hair extensions style consciousness and sculpting skills. Use the versatile variations of a short crop to make a different impression each time you attend and event. Drop a glimpse at these Tape Hair Extensions unique examples to see how you can master the art of creating some of the coolest mohawks.
coach88888888 Email
2012-8-13 17:55
If you desire to go to Coach Factory Outlet, but have no idea in which to go, you can research online. It is no doubt that there is drastically information and details about it for the reference.Coach Factory Online are loved by many people, when you walk in the street, you could see many people take coach styles.hat experts claim Coach Outlet Online shopping is in the changes they are available in.Coach Outlet will send you a coupon in the post to use in their upon only after you type a achieve. The Coach bags are customarily somewhat many than the ones in the stores.
baozang
2012-9-22 13:34
Lamo - Like Sebago, Louis Vuitton Canada  there are only about 40 styles of Lamo Footwear. Most of their footwear uses a suede leather traditional in True Religion Jeans  moccasins, though only about 1/3 of the footwear collection is a traditional moccasin look. True Religion Brand Jeans The rest of the collection is slippers and UGG styled boots.Louis Vuitton Artsy The traditional moccasins do have a soft rubber sole making them great deck True Religion Sale shoes as well, however. Expect to pay between $50 and $60 for Lamo moccasins.  Invicta watches have been here since 1837. They were made by Raphael Picard. Invicta watches got its name from a Latin word. The meaning of Invicta in Louis Vuitton Monogram Vernis Alma BB Amarante Latin is "Invincible". Earlier these watches were not so popular but recently with its new men's collection this watch brand has gained a lot of popularity. Watches for many are a style statement and so they prefer to own the best piece. Invicta watches are popular as they are like a style statement.
韩岭在拈 Email
2012-12-26 18:06
修改一级建造师考试分数修改二级建造师考试分数(QQ:862488826)
GAWERW
2013-3-5 13:45
买轴承就到:www.jkzhoucheng.cn
厦门最好的花场ktv是www.nyjzktv.com
[2013-5-4 11:03]
来源:曹盲竺幽
内容:厦门最好的夜场是www.nyjzktv.com
厦门夜场招聘首选www.nyjzktv.com
厦门最好的ktv是www.nyjzktv.com
skincarecounsel Email Homepage
2013-6-10 16:15
感謝分享這個腳本。非常有幫助。anti aging cream  fhr9vmg7
click here Email Homepage
2013-7-18 08:09
谢谢你分享这个公式有这个讨论。这是非常有用的。click here
磨延城 Email Homepage
2013-10-21 20:57
磨途歌学习了
aa Email Homepage
2015-1-14 20:06
好无聊啊
分页: 2/3 第一页 上页 1 2 3 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]