Writing a module to use with http_proxy

Hi. I’m new to nginx module development and I’m going to write a module
that must do everything that http_proxy module does except it must do
some checks before request is passed to the upstream. What’s the best
way to do that?

Thank you.

Posted at Nginx Forum:

To be more precise I need some functionalty to check request and pass it
to some (formed manually) other url if it passes check procedure and if
the check fails - return 404 back to client.

Thank you.

Posted at Nginx Forum:

I’ve tried to start and I faced a ‘segmentation fault’ error. I tried to
add handler to NGX_HTTP_ACCESS_PHASE and that causes segmentation fault.
Here’s the code. Init function is called from merge_loc_conf

// auth check handler
static ngx_int_t ngx_http_zd_aws_proxy_check(ngx_http_request_t *r)

// Config initializer, adds core handler to check auth
static ngx_int_t ngx_http_zd_aws_proxy_init(ngx_conf_t *cf)

ngx_http_handler_pt        *h;
ngx_http_core_main_conf_t  *cmcf;

cmcf = ngx_http_conf_get_module_main_conf(cf,


h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
if (h == NULL) {
    return NGX_ERROR;

*h = ngx_http_zd_aws_proxy_check;

return NGX_OK;


Any thoughts on that ?

Thank you.

Posted at Nginx Forum:

I’ve resolved the problem by addind ‘init’ function into
postconfiguration slot of module context.
The next problem is to find out how to get module conf variables from

Posted at Nginx Forum: