# Cloudflare: プロキシ機能、サーバセキュリティ、Certbot DNS-01チャレンジ、WARP Client

**URL:** https://forum.ficusonline.com/t/topic/494
**Category:** Server
**Tags:** cloudflare, security, dns, certbot
**Created:** [2023 年 10 月 3 日午前 8:00 UTC](https://forum.ficusonline.com/t/topic/494 "2023-10-03T08:00:55Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2023 年 10 月 5 日午前 12:43 UTC](https://forum.ficusonline.com/t/topic/494/2 "2023-10-05T00:43:06Z")

</div>

Cloudflareプロキシ経由のクライアントIPアドレスの引継ぎはNginxの ngx\_http\_realip\_module を利用します。以下記事参照。

> [@NGINX 設定ティップス](https://forum.ficusonline.com/t/topic/333/20):
>
> 外部サーバへのリバースプロキシ設定 ドメイン名でのみでアクセス許可した外部 Nginx サーバ（バックエンド）へのプロキシ（フロントエンド）設定。 簡単に言うとフロントエンドで受けたドメイン名をバックエンドへ引継ぐための設定です。 リバースプロキシ側（フロントエンド）で、下記 proxy\_set\_header で指定したヘッダー情報を外部サーバ（バックエンド）へ受け渡します。 Note） …

 ![Restoring_IPs](https://forum.ficusonline.com/uploads/default/original/2X/a/a829eebcf44594754731216545f4f52cfa442989.png)

Nginxで追加する設定ファイルは以下の通りです。

**`real_ip_header`** は **Cloudflare** が指定する **`CF-Connecting-IP`** に置換えます。

**`/etc/nginx/conf.d/real_ip_recursive.conf`**

```auto
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 104.24.0.0/14;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 192.168.0.0/16;
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32;
set_real_ip_from 2a06:98c0::/29;
set_real_ip_from 2c0f:f248::/32;
real_ip_header CF-Connecting-IP;
real_ip_recursive on;

```

### Restoring original visitor IPs

> **[Restoring original visitor IPs](https://developers.cloudflare.com/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/)**
>
> When your website traffic is routed through the Cloudflare network, we act as a reverse proxy. This allows Cloudflare to speed up page load time by routing packets more efficiently and caching static resources (images, JavaScript, CSS, etc.). As a...

### CF-Connecting-IP (HTTP request headers)

> **[Cloudflare HTTP headers](https://developers.cloudflare.com/fundamentals/reference/http-headers/)**
>
> Cloudflare passes all HTTP request headers to your origin web server and adds additional headers as specified below.

### Cloudflare IP Ranges

> **[IP Ranges](https://www.cloudflare.com/ips/)**
>
> This page is intended to be the definitive source of Cloudflare’s current IP ranges.

---

_[View the full topic](https://forum.ficusonline.com/t/topic/494)._
