[文章作者:张宴 本文版本: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) | 阅读(77208)
Steven Email Homepage
2015-3-19 02:58
Thank you for this post Weight Loss Tea
instagram online Email Homepage
2018-10-10 19:07
Thank you so much for sharing this instagram technology post, it's what I need to find.
katedaisy
2020-4-10 17:44
Looks extremely good, although I'm the opposite of you but I enjoy it driving directions
kevinmalone01 Email Homepage
2021-2-12 18:06
You can solve Quickbooks Errors by using some methods which are defined for specific errors. You can also solve Qb errors by using Quickbooks Tool Hub. In that, there are many tools available through which you can solve different problems.https://updateerror.co/
shz Email
2022-7-18 19:11
I see some amazingly important and kept up to length of your strength searching for in your on the site  Scam Risk
shzz Email
2022-7-18 19:18
I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.  Scam Risk
shz Email
2022-7-18 19:22
I think it could be more general if you get a football sports activity  Scam Risk
shzz Email
2022-7-18 19:22
I would recommend my profile is important to me, I invite you to discuss this topic...  Scam Risk
shz Email
2022-7-18 19:26
Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one.  Scam Risk
shzz Email
2022-7-18 19:26
I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job  Scam Risk
shzz Email
2022-7-18 19:32
I think about it is most required for making more on this get engaged  Scam Risk
shz Email
2022-7-18 19:34
Your music is amazing. You have some very talented artists. I wish you the best of success.  Scam Risk
shzz Email
2022-7-18 19:36
There is definately a great deal to know about this subject. I like all of the points you've made.  Scam Risk
Jack Homepage
2022-9-3 20:42
QuickBooks is a full-featured business and financial management suite complete with tools for accounting, inventory, payroll, tax filing, invoicing, etc. https://lchilltopnews.org/quickbooks-clean-installtool/https://latestguestpost.com/quickbooks-clean-install-tool/https:/...
Lucky cola
2024-2-7 16:41
Level up, power up, and show off your gaming skills.  Lucky cola
分页: 3/3 第一页 上页 1 2 3 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]