CDN获取不了真实IP
鎴戜娇鐢ㄧ殑鏄張鎷嶄簯,浠栦笂闈㈡湁鏂囨。,浣嗘槸鎴戜笉鐭ラ亾DZ鏄庝箞淇敼,楹荤儲鍝綅澶т浆璇锋暀涓涓,绾挎妸浠g爜鍏竷鍑烘潵
濡備綍鑾峰彇鏈缁堢敤鎴 IP 锛露
server { listen 80; add_header X-Real-IP $http_x_real_ip; }
1 璐$尞鏈浣崇瓟妗
淇敼鏂囦欢 source\class\discuz\discuz_application.php
鎼滅储
private function _get_client_ip() {
鎵惧埌
$ip = $_SERVER['REMOTE_ADDR'];
鍦ㄤ笅闈㈠姞涓
濡備綍鑾峰彇鏈缁堢敤鎴 IP 锛露
鍙堟媿浜 CDN 鍥炲鎴锋簮鐨勬椂鍊欎細甯︿笂 X-Real-IP 鍜 X-Forwarded-For 鐨勮姹傚ご涓嬪幓锛屽间负鐢ㄦ埛瀹為檯璁块棶 CDN 鐨勬潵婧 IP 鍦板潃銆傜壒鍒湴锛屼负浜嗗吋瀹归儴鍒嗘湇鍔$绋嬪簭锛屾垜浠澶栬繕鎻愪緵浜 Client-IP 璇锋眰澶寸殑鏀寔锛屽叾鍊煎拰 X-Real-IP銆乆-Forwarded-For 鐩稿悓銆
绀轰緥涓锛歅HP 浠g爜露
绀轰緥浜岋細 Nginx 閰嶇疆露
server { listen 80; add_header X-Real-IP $http_x_real_ip; }
1 璐$尞鏈浣崇瓟妗
淇敼鏂囦欢 source\class\discuz\discuz_application.php
鎼滅储
private function _get_client_ip() {
鎵惧埌
$ip = $_SERVER['REMOTE_ADDR'];
鍦ㄤ笅闈㈠姞涓
- if(isset($_SERVER['HTTP_X_REAL_IP'])) $ip=$_SERVER['HTTP_X_REAL_IP'];
- 璇︾粏绛旀 >