オリジンルール
オリジンルールを使用すると、受信トラフィックの行き先やパラメータをカスタマイズできます。現在、以下のオーバーライドを実行できます:
- Hostヘッダー: 受信リクエストの
Hostヘッダーをオーバーライドします。 - サーバー名表示(SNI): 受信リクエストのサーバー名表示(SNI)値をオーバーライドします。
- DNSレコード: 受信リクエストの解決されたホスト名をオーバーライドします。
- 宛先ポート: 受信リクエストの解決された宛先ポートをオーバーライドします。
オリジンルールの式は、これらのオーバーライドが適用されるタイミングを決定します。
For more complex およびカスタマイズされた変更, consider using Snippets.
Cloudflare provides you with rules templates for common use cases. In the dashboard, go to your zone > Rules > Templates and select one of the available templates. You can also refer to the Examples gallery in the developer docs.
| Free | Pro | Business | Enterprise | |
|---|---|---|---|---|
Availability | Yes | Yes | Yes | Yes |
Number of rules | 10 | 25 | 50 | 125 |
Override Host header | No | No | No | Yes |
Override SNI | No | No | No | Yes |
Override DNS records | No | No | No | Yes |
Override destination port | Yes | Yes | Yes | Yes |
The execution order of Rules features is the following:
The different types of rules listed above will take precedence over Page Rules. This means that Page Rules will be overridden if there is a match for both Page Rules and the Rules products listed above.
Generally speaking, for non-terminating actions the last change made by rules in the same phase will win (later rules can overwrite changes done by previous rules). However, for terminating actions (Block, Redirect, or one of the challenge actions), rule evaluation will stop and the action will be executed immediately.
For example, if multiple rules with the Redirect action match, Cloudflare will always use the URL redirect of the first rule that matches. Also, if you configure URL redirects using different Cloudflare products (Single Redirects and Bulk Redirects), the product executed first will apply, if there is a rule match (in this case, Single Redirects). Refer to the Phases list for the product execution order.
オリジンルールでホスト名をオーバーライドする場合(HostヘッダーオーバーライドまたはDNSレコードオーバーライドを介して)、ロードバランサーの設定にヘッダーオーバーライドを追加すると、オリジンルールがロードバランサーの設定に優先します。
ページルールと同様に、Hostヘッダーオーバーライドを実行するオリジンルールは、元のリクエストのSNI値をHostヘッダーと同じ値に更新します。Hostヘッダーオーバーライドとは異なるSNI値を設定するには、同じオリジンルールにSNIオーバーライドを追加するか、この目的のために別のオリジンルールを作成してください。
When troubleshooting オリジンルール, use Cloudflare Trace to determine if a rule is triggering for a specific URL.