LoginSignup
2
1

More than 5 years have passed since last update.

Bluemix CF アプリケーションでのIPアドレスの取得

Last updated at Posted at 2017-06-16

BluemixのCFアプリケーションは、一般的なCF環境と同様に実行時のコンテナのIPアドレスを環境変数(CF_INSTANCE_IP)経由で取得することが出来る。

簡単に表示できるのでPHPのRuntimeを使った場合、index.php を次のように下記変えて実施(他の言語の場合でも同じように)

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="style.css" />
</head>
<body>

    <table>

<?php

    foreach ( $_ENV as $k => $v) {
        echo "<tr><td>$k </td><td> $v </td></tr>";
    }
?>

    </table>
</body>
</html>

この取得できる中でも特に以下のまわりがアドレスまわりとなる。

  • CF_INSTANCE_IP
  • CF_INSTANCE_ADDR
  • CF_INSTANCE_PORT
  • CF_INSTANCE_PORTS
  • CF_INSTANCE_GUID
  • CF_INSTANCE_INDEX

各値の説明はだいたい名前でわかると思いますがCFのマニュアルに定義されています。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1