Message Processor の 405 プロパティに ignore allow ヘッダーを構成する

Apigee Edge のドキュメントを表示しています。
Apigee X のドキュメントに移動します。
情報

クライアントとサーバーの通信において、クライアントが提示した HTTP リクエスト メソッドがサーバーに認識されているものの、ターゲット リソースでサポートされていない場合、サーバーは HTTP ステータス コード 405 Method Not Allowed で応答します。同様に、Apigee Edge では、バックエンド サーバーが HTTP ステータス コード 405 Method Not Allowed. で応答できます。

Apigee Edge は、仕様の RFC 7231 のセクション 6.5.5: 405 Method Not Allowed に従って、バックエンド サーバーが Allow ヘッダーに許可されたメソッドのリストを含む 405 Method Not Allowed レスポンスを送信することを想定しています。

Allow ヘッダーは次の形式で送信する必要があります。

Allow: HTTP_METHODS

たとえば、バックエンド サーバーで GETPOSTHEAD メソッドが許可されている場合は、Allow ヘッダーに次のように含まれていることを確認する必要があります。

Allow: GET, POST, HEAD

バックエンド サーバーが HTTP ステータス コード 405 Method Not Allowed,Allow ヘッダーを送信しない場合、Apigee はエラーコード protocol.http.Response405WithoutAllowHeader で HTTP ステータス コード 502 Bad Gateway をクライアント アプリケーションに返します。このエラーに対処するための推奨される解決策は、 RFC 7231 のセクション 6.5.5: 405 Method Not Allowed の仕様に準拠するようにバックエンド サーバーを修正するか、障害処理を使用して、トラブルシューティング プレイブックの 502 Bad Gateway - Response 405 without Allow header で説明されているように、Allow ヘッダーを含む HTTP ステータス コード 405 Method Not Allowed で応答することです。

ただし、例外的なケースでは、バックエンドを修正したり、API プロキシを変更してこの問題をすぐに解決できない場合があります。

このような場合は、Message Processor レベルで 405 プロパティ HTTP.ignore.allow_header.for.405 の ignore allow ヘッダーを一時的に設定できます。このプロパティを true に設定すると、バックエンド サーバーが Allow ヘッダーなしで HTTP ステータス コード 405 Method Not Allowed を送信した場合でも、Apigee がクライアント アプリケーションに 502 Bad Gateway レスポンスを返すのを防ぐことができます。

バックエンド サーバーを修正して Allow ヘッダーで HTTP ステータス コード 405 Method Not Allowed を送信できるようになったら、プロパティ HTTP.ignore.allow_header.for.405 をデフォルト値 false に戻すことができます。

始める前に

このドキュメントの手順を使用する前に、次のトピックを理解しておいてください。

Message Processor の 405 プロパティに ignore allow ヘッダーを true に構成する

Apigee Edge では、デフォルトでプロパティ HTTP.ignore.allow_header.for.405false に設定されています。これにより、バックエンド サーバーが Allow ヘッダーなしで HTTP ステータス コード 405 Method Not Allowed を送信した場合、Apigee Edge はエラーコード protocol.http.Response405WithoutAllowHeader502 Bad Gateway をクライアント アプリケーションに返すことができます。Apigee Edge がクライアント アプリケーションに 502 Bad Gateway を送信しないようにするには、Message Processor でプロパティ HTTP.ignore.allow_header.for.405 の値を true に設定する必要があります。

このセクションでは、 Edge の構成方法で説明されている構文に従ってトークンを使用し、Message Processor でプロパティ HTTP.ignore.allow_header.for.405true に構成する方法について説明します。

  1. Message Processor マシンで、次のファイルをエディタで開きます。存在しない場合は作成します。

    /opt/apigee/customer/application/message-processor.properties

    たとえば、 vi を使用してファイルを開くには、次のように入力します。

    vi /opt/apigee/customer/application/message-processor.properties
  2. プロパティ ファイルに次の形式の行を追加します。
    conf_http_HTTP.ignore.allow_header.for.405=true
  3. 変更を保存します。
  4. プロパティ ファイルの所有者が apigee ユーザーであることを確認します。
    chown apigee:apigee /opt/apigee/customer/application/message-processor.properties
    
  5. 次のように Message Processor を再起動します。
    /opt/apigee/apigee-service/bin/apigee-service edge-message-processor restart
    
  6. 複数の Message Processor がある場合は、すべての Message Processor で上記の手順を繰り返します。

Message Processor で 405 プロパティの ignore allow ヘッダーが true に設定されていることを確認する

このセクションでは、Message Processor でプロパティ HTTP.ignore.allow_header.for.405true に正常に更新されたことを確認する方法について説明します。

トークン conf_http_HTTP.ignore.allow_header.for.405 を使用して Message Processor のプロパティの値を更新しても、実際のプロパティ HTTP.ignore.allow_header.for.405true に設定されているかどうかを確認する必要があります。

  1. Message Processor マシンで、/opt/apigee/edge-message-processor/conf ディレクトリのプロパティ HTTP.ignore.allow_header.for.405 を検索し、次のように true に設定されているかどうかを確認します。
    grep -ri "HTTP.ignore.allow_header.for.405" /opt/apigee/edge-message-processor/conf
    
  2. Message Processor でプロパティが正常に更新されると、上記のコマンドは、次の例に示すように、http.properties ファイルのプロパティ HTTP.ignore.allow_header.for.405 の値を true として表示します。
    /opt/apigee/edge-message-processor/conf/http.properties:HTTP.ignore.allow_header.for.405=true
  3. プロパティ HTTP.ignore.allow_header.for.405 の値が false のままの場合は、Message Processor の 405 プロパティに ignore allow ヘッダーを true に構成するで説明されているすべての手順を正しく実行したことを確認します。手順を間違えた場合は、すべての手順を正しく繰り返します。
  4. それでもプロパティ HTTP.ignore.allow_header.for.405 を変更できない場合は、Apigee Edge サポートにお問い合わせください。

Message Processor の 405 プロパティに ignore allow ヘッダーを false に構成する

このセクションでは、Edge の構成方法で説明されている構文に従ってトークンを使用し、Message Processor でプロパティ HTTP.ignore.allow_header.for.405 をデフォルト値 false に構成する方法について説明します。

  1. プロパティ HTTP.ignore.allow_header.for.405true に変更されているかどうかを確認します。これを行うには、/opt/apigee/edge-message-processor/conf ディレクトリでこのプロパティを検索し、次のコマンドを使用してその値を確認します。
    grep -ri "HTTP.ignore.allow_header.for.405" /opt/apigee/edge-message-processor/conf
    
  2. Message Processor でプロパティが true に設定されている場合、上記のコマンドを実行すると、次の例のように、http.properties ファイルのプロパティ HTTP.ignore.allow_header.for.405 の値が true として表示されます。
    /opt/apigee/edge-message-processor/conf/http.properties:HTTP.ignore.allow_header.for.405=true
  3. 上記のコマンドで、プロパティ HTTP.ignore.allow_header.for.405false(デフォルト値)に設定されていることが示された場合は、何もする必要はありません。つまり、以下の手順をスキップします。
  4. プロパティ HTTP.ignore.allow_header.for.405true に設定されている場合は、次の手順でデフォルト値 false に戻します。
  5. Message Processor マシンで、次のファイルをエディタで開きます。

    /opt/apigee/customer/application/message-processor.properties

    たとえば、 vi を使用してファイルを開くには、次のように入力します。

    vi /opt/apigee/customer/application/message-processor.properties
    
  6. プロパティ ファイルから次の行を削除します。
    conf_http_HTTP.ignore.allow_header.for.405=true
  7. 変更を保存します。
  8. プロパティ ファイルの所有者が apigee ユーザーであることを確認します。
    chown apigee:apigee /opt/apigee/customer/application/message-processor.properties
    
  9. 次のように Message Processor を再起動します。
    /opt/apigee/apigee-service/bin/apigee-service edge-message-processor restart
    
  10. 複数の Message Processor がある場合は、すべての Message Processor で上記の手順を繰り返します。

Message Processor で 405 プロパティの ignore allow ヘッダーが false に設定されていることを確認する

このセクションでは、Message Processor でプロパティ HTTP.ignore.allow_header.for.405false に正常に更新されたことを確認する方法について説明します。

トークン conf_http_HTTP.ignore.allow_header.for.405 を使用して Message Processor の値を更新しても、実際のプロパティ HTTP.ignore.allow_header.for.405false に設定されているかどうかを確認する必要があります。

  1. Message Processor マシンで、/opt/apigee/edge-message- processor/conf ディレクトリのプロパティ HTTP.ignore.allow_header.for.405 を検索し、次のように false に設定されているかどうかを確認します。
    grep -ri "HTTP.ignore.allow_header.for.405" /opt/apigee/edge-message-processor/conf
    
  2. Message Processor でプロパティが正常に更新されると、上記のコマンドは、次の例に示すように、http.properties ファイルのプロパティ HTTP.ignore.allow_header.for.405 の値を false として表示します。
    /opt/apigee/edge-message-processor/conf/http.properties:HTTP.ignore.allow_header.for.405=false
  3. プロパティ HTTP.ignore.allow_header.for.405 の値が true のままの場合は、 Message Processor の 405 プロパティに ignore allow ヘッダーを false に構成するで説明されているすべての手順を正しく実行したことを確認します。手順を間違えた場合は、すべての手順をもう一度正しく繰り返します。
  4. それでもプロパティ HTTP.ignore.allow_header.for.405 を変更できない場合は、Apigee Edge サポートにお問い合わせください。