0
我们有什么:Nginx的proxy_pass饼干
- 一堆的Apache Nginx的。
- 论坛Tinyboard。
通过Apache授权正常进行,但nginx的一个功能mkhash:
function mkhash($username, $password, $salt = false) {
global $config;
if (! $salt) {
// Create some sort of salt for the hash
$salt = substr(base64_encode(sha1(rand(). time(), true). $config['cookies']['salt']), 0 , 15) ;
$generated_salt = true;
}
// Generate hash (method is not important as long as it's strong)
$hash = substr(base64_encode(md5($username . $config['cookies']['salt']. sha1($username . $password . $salt . ($config['mod']['lock_ip']? $_SERVER['REMOTE_ADDR']:''), true), true)), 0 , 20);
if (isset($generated_salt))
return array($hash, $salt);
else
return $hash;
}
不返回正确的值和授权失败。 核查如下:
if ($cookie[ 1 ]! == mkhash($cookie[0], $user['password'], $cookie[2]) {
// Malformed cookies
destroyCookies();
mod_login();
exit;
}
为了成功登录条件不应该被执行。
实施例经由nginx的返回值(登录失败):
- cookie0:管理员
- COOKIE1:Ib37H5U7hCi6Br9M09V
- COOKIE2:Nn2wUxlnirvgzkn
- mkhash:fN1jv3t9ccThde0Kp30h
实施例通过apache返回值(登录成功):
- cookie0:管理员
- COOKIE1:SgaMoQ07upLoz9Q7Wdz6
- COOKIE2:Zp6BQ2b20Jsh 1R
- mkhash:SgaMoQ07upLoz9Q7Wdz6
阿帕奇挂在端口82(如果处理得当该端口身份验证是成功的)。 Nginx本身只接受静态文件,动态内容来自Apache。究竟是什么原因?
location/{
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}
这可能是不相关的PHP代码,但您的服务器组态。尝试使用echo或类似来调试cookie值,以确保它们通过nginx传递,并且如果它们没有发布您的nginx proxy_pass配置 – foibs