dtgu21994537 2019-07-08 23:42
浏览 33
已采纳

使用PHP包含负载均衡器,我可以只包含来自服务器A的文件

If I'm using a load balancer with 2 droplets on Digital Ocean.

I want to use a PHP include for an HTML file.

is there anyway to only include the file from server A, not server B?

The use case is that these html files are generated by my customer, and will be written to a single server.

  • 写回答

1条回答 默认 最新

  • dongzhi1904 2019-07-09 00:05
    关注

    You can write an if statement:

    if ($_SERVER['SERVER_NAME'] == "servera.yourdomain.com") {
        include("file.html");
    } else {
        include("http://servera.yourdomain.com/path/to/file.html");
    }
    

    Note that this will only work for static files like HTML. If you try to include a PHP file through the webserver, it will be executed on the remote server instead of returning the source code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程