comparison src/http/ngx_http_upstream.c @ 5231:05c53652e7b4

Upstream: http_403 support in proxy_next_upstream (and friends). The parameter is mostly identical to http_404, and is expected to be used in similar situations. The 403 code might be returned by a backend instead of 404 on initial sync of new directories with rsync. See here for feature request and additional details: http://mailman.nginx.org/pipermail/nginx-ru/2013-April/050920.html
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 27 May 2013 16:54:09 +0400
parents ddba4e308ecc
children af60a210cb78
comparison
equal deleted inserted replaced
5230:2139768ee404 5231:05c53652e7b4
367 static ngx_http_upstream_next_t ngx_http_upstream_next_errors[] = { 367 static ngx_http_upstream_next_t ngx_http_upstream_next_errors[] = {
368 { 500, NGX_HTTP_UPSTREAM_FT_HTTP_500 }, 368 { 500, NGX_HTTP_UPSTREAM_FT_HTTP_500 },
369 { 502, NGX_HTTP_UPSTREAM_FT_HTTP_502 }, 369 { 502, NGX_HTTP_UPSTREAM_FT_HTTP_502 },
370 { 503, NGX_HTTP_UPSTREAM_FT_HTTP_503 }, 370 { 503, NGX_HTTP_UPSTREAM_FT_HTTP_503 },
371 { 504, NGX_HTTP_UPSTREAM_FT_HTTP_504 }, 371 { 504, NGX_HTTP_UPSTREAM_FT_HTTP_504 },
372 { 403, NGX_HTTP_UPSTREAM_FT_HTTP_403 },
372 { 404, NGX_HTTP_UPSTREAM_FT_HTTP_404 }, 373 { 404, NGX_HTTP_UPSTREAM_FT_HTTP_404 },
373 { 0, 0 } 374 { 0, 0 }
374 }; 375 };
375 376
376 377
3154 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock); 3155 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
3155 #endif 3156 #endif
3156 3157
3157 if (u->peer.sockaddr) { 3158 if (u->peer.sockaddr) {
3158 3159
3159 if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404) { 3160 if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_403
3161 || ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404)
3162 {
3160 state = NGX_PEER_NEXT; 3163 state = NGX_PEER_NEXT;
3164
3161 } else { 3165 } else {
3162 state = NGX_PEER_FAILED; 3166 state = NGX_PEER_FAILED;
3163 } 3167 }
3164 3168
3165 u->peer.free(&u->peer, u->peer.data, state); 3169 u->peer.free(&u->peer, u->peer.data, state);
3185 status = NGX_HTTP_GATEWAY_TIME_OUT; 3189 status = NGX_HTTP_GATEWAY_TIME_OUT;
3186 break; 3190 break;
3187 3191
3188 case NGX_HTTP_UPSTREAM_FT_HTTP_500: 3192 case NGX_HTTP_UPSTREAM_FT_HTTP_500:
3189 status = NGX_HTTP_INTERNAL_SERVER_ERROR; 3193 status = NGX_HTTP_INTERNAL_SERVER_ERROR;
3194 break;
3195
3196 case NGX_HTTP_UPSTREAM_FT_HTTP_403:
3197 status = NGX_HTTP_FORBIDDEN;
3190 break; 3198 break;
3191 3199
3192 case NGX_HTTP_UPSTREAM_FT_HTTP_404: 3200 case NGX_HTTP_UPSTREAM_FT_HTTP_404:
3193 status = NGX_HTTP_NOT_FOUND; 3201 status = NGX_HTTP_NOT_FOUND;
3194 break; 3202 break;