Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $upstream_addr contains name of upstream
- To: nginx-ru@xxxxxxxxx
- Subject: Re: $upstream_addr contains name of upstream
- From: Konstantin Svist <fry.kun@xxxxxxxxx>
- Date: Tue, 15 Dec 2009 01:34:29 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=AnyNvH56JC/mouLxODUpue5SiWNKl39tvmO42ntYSgs=; b=NsO/9AlAG1z3ycQSuce0Iwc7BQqCLJ42TwJNTjh0quvAWCWwS2QfWYUT8x7NOv5Ss0 eXkLOTibc70qfG8V3ULyhbYJRFuz4qDo5G7ORW2IAAmCtQ6o2/OYTXY5QVru7RH3YI1t L8fKz3FfIkoAl7hL+nwtsUO5mgfQfu3i4iViY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=Ck+sx7NdxEC31RRbXdp68l3G/d5Q6466wO+QtWCDFVEbMCix3FSK0MJlowGLIaOfz1 w/UL3UWY5ZgIl6InDxkyGWXlSkkDbAQFWqmufOzHJhz0lsKknbsbz9sflk2PJoQcYuIC uwqt+Bg+QjVrLR/QK6uVEZK6W1e5QCIlUwkxE=
- In-reply-to: <20091215073749.GB2727@xxxxxxxxxxx>
- References: <4B2566E8.1010802@xxxxxxxxx> <20091214132111.GA2727@xxxxxxxxxxx> <4B26CFF9.2090802@xxxxxxxxx> <20091215073749.GB2727@xxxxxxxxxxx>
On 12/14/2009 11:37 PM, Sergey A. Osokin wrote:
On Mon, Dec 14, 2009 at 03:53:29PM -0800, Konstantin Svist wrote:
On 12/14/2009 05:21 AM, Sergey A. Osokin wrote:
Добрый день,
On Sun, Dec 13, 2009 at 02:12:56PM -0800, Konstantin Svist wrote:
upstream redisxxx {
server unix:/tmp/redis-http-cache.sock;
server localhost:6381;
server localhost:1111;
}
server {
location / {
...
redis_pass redisxxx;
error_page 404 500 502 504 = @real-backend;
}
location @real-backend {
proxy_pass http://backend
proxy_set_header lastcache $upstream_addr;
}
}
localhost:1111 порт закрыт; два других одинаковый сервер, всегда
возвращают 404
3 запроса на backend показывают header:
Lastcache: unix:/tmp/redis-http-cache.sock ~правильно
Lastcache: 127.0.0.1:1111, 127.0.0.1:6381 ~правильно
Lastcache: redisxxx ~глюка
есть возможность реализовать такую же конфигурацию, но на memcached?
Будет ли проявлятся ошибка?
Попробовал - memcached возвращает 404 когда ключ не найден
($upstream_status), и имя upstream-а не появляется в $upstream_addr
redis отвечает 502 на случай когда ключ не найден.
Подскажите номер версии nginx для тестов.
0.8.29
вот патч, кажется работает
--- ngx_http_redis_module.c.old 2009-12-14 17:06:34.000000000 -0800
+++ ngx_http_redis_module.c 2009-12-14 17:06:44.000000000 -0800
@@ -344,7 +344,7 @@
found:
- *p = '\0';
+ //*p = '\0';
line.len = p - u->buffer.pos - 1;
line.data = u->buffer.pos;
@@ -356,9 +356,8 @@
ctx = ngx_http_get_module_ctx(r, ngx_http_redis_module);
- if (ngx_strcmp(p, "-ERR") == 0) {
- ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
- "error was received from redis");
+ if (ngx_strncmp(p, "-ERR", sizeof("-ERR")-1) == 0) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, "error was
received from redis");
u->headers_in.status_n = 404;
u->state->status = 404;
@@ -366,13 +365,12 @@
return NGX_OK;
}
- if (ngx_strcmp(p, "+OK\x0d") == 0) {
- p += sizeof("+OK") - 1 + sizeof(CRLF) - 1;
+ if (ngx_strncmp(p, "+OK\r\n", sizeof("+OK\r\n")-1) == 0) {
+ p += sizeof("+OK\r\n") - 1;
}
-
- if (ngx_strcmp(p, "$-1\x0d") == 0) {
- ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
- "key: \"%V\" was not found by redis", &ctx->key);
+
+ if (ngx_strncmp(p, "$-1\r\n", sizeof("$-1\r\n")-1) == 0) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, "key: \"%V\"
was not found by redis", &ctx->key);
u->headers_in.status_n = 404;
u->state->status = 404;
_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://nginx.org/mailman/listinfo/nginx-ru
|