顯示頁面舊版反向連結Fold/unfold all回到頁頂 本頁是唯讀的,您可以看到原始碼,但不能更動它。您如果覺得它不應被鎖上,請詢問管理員。 ====== 由 Cloudflare 擔任 CDN 設定 log 顯示用戶實際 IP (Apache) ====== * 如果是 Nginx 可以參考 [[nginx_proxy_real_ip]] * 設定環境 : Debian GNU/Linux 10 ===== 設定方式 ===== - 使用 root 權限操作 <cli>sudo -i</cli> - 啟動 remoteip <cli>sa2enmod remoteip</cli> - 更新 000-default.conf 設定, 加入 RemoteIPHeader CF-Connecting-IP<cli>vi /etc/apache2/sites-available/000-default.conf</cli><file> : # modules, e.g. #LogLevel info ssl:warn RemoteIPHeader CF-Connecting-IP ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are : </file> - 設定 Cloudflare 的 IP <cli>vi /etc/apache2/conf-available/remoteip.conf</cli><file> RemoteIPHeader CF-Connecting-IP RemoteIPTrustedProxy 173.245.48.0/20 RemoteIPTrustedProxy 103.21.244.0/22 RemoteIPTrustedProxy 103.22.200.0/22 RemoteIPTrustedProxy 103.31.4.0/22 RemoteIPTrustedProxy 141.101.64.0/18 RemoteIPTrustedProxy 108.162.192.0/18 RemoteIPTrustedProxy 190.93.240.0/20 RemoteIPTrustedProxy 188.114.96.0/20 RemoteIPTrustedProxy 197.234.240.0/22 RemoteIPTrustedProxy 198.41.128.0/17 RemoteIPTrustedProxy 162.158.0.0/15 RemoteIPTrustedProxy 104.16.0.0/12 RemoteIPTrustedProxy 172.64.0.0/13 RemoteIPTrustedProxy 131.0.72.0/22 RemoteIPTrustedProxy 2400:cb00::/32 RemoteIPTrustedProxy 2606:4700::/32 RemoteIPTrustedProxy 2803:f800::/32 RemoteIPTrustedProxy 2405:b500::/32 RemoteIPTrustedProxy 2405:8100::/32 RemoteIPTrustedProxy 2a06:98c0::/29 RemoteIPTrustedProxy 2c0f:f248::/32 </file> - 檢查設定格是是否有異常 <cli>apache2ctl configtest</cli> - 重新啟動 apache <cli>systemctl restart apache2</cli> ===== 參考網址 ===== * https://support.cloudflare.com/hc/en-us/articles/200170786-Restoring-original-visitor-IPs {{tag>Cloudflare proxy realip apache}} tech/cloudflare_proxy_real_ip.txt 上一次變更: 2021/11/30 23:14由 jonathan