proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
/**
* 獲取客户端ip
*/
function getClientIP() {
$ip = "unknown";
/*
* 訪問時用localhost訪問的,讀出來的是“::1”是正常情況。
* ::1說明開啟了ipv6支持,這是ipv6下的本地回環地址的表示。
* 使用ip地址訪問或者關閉ipv6支持都可以不顯示這個。
* */
if (isset($_SERVER)) {
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} elseif (isset($_SERVER["HTTP_CLIENT_ip"])) {
$ip = $_SERVER["HTTP_CLIENT_ip"];
} else {
$ip = $_SERVER["REMOTE_ADDR"];
}
} else {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_CLIENT_ip')) {
$ip = getenv('HTTP_CLIENT_ip');
} else {
$ip = getenv('REMOTE_ADDR');
}
}
if(trim($ip)=="::1"){
$ip="127.0.0.1";
}
return $ip;
}
$_SERVER['SERVER_NAME'];
歡迎光臨 ADJ網路實驗室 (http://dz.adj.idv.tw/) | Powered by Discuz! 6.0.0 |