return 403 instead of next phase

Donatas Abraitis donatas.abraitis at
Mon Aug 25 14:07:12 UTC 2014


static ngx_int_t ngx_http_hostprotect_init(ngx_conf_t *cf)
  ngx_http_handler_pt *h;
  ngx_http_core_main_conf_t *cscf;

  cscf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
  h = ngx_array_push(&cscf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
  if(h == NULL)
    return NGX_ERROR;

  *h = ngx_http_hostprotect_handler;

  return NGX_OK;

static ngx_int_t ngx_http_hostprotect_handler(ngx_http_request_t *r)
    r->headers_out.status = NGX_HTTP_FORBIDDEN;
    r->headers_out.content_length_n = sizeof(err_msg);
    return ngx_http_output_filter(r, &out);

Everything looks fine, but backend (in this case Apache) still receives
requests. Any options to drop the request without allowing it to reach

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list