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 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭