Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ngx_config.h>
- #include <ngx_core.h>
- #include <ngx_http.h>
- static ngx_int_t ngx_http_neonginx_test_init(ngx_conf_t *cf);
- static ngx_int_t ngx_http_neonginx_test_handler(ngx_http_request_t *r);
- static ngx_http_module_t ngx_http_neonginx_test_module_ctx = {
- NULL, /* preconfiguration */
- ngx_http_neonginx_test_init, /* postconfiguration */
- NULL, /* create main configuration */
- NULL, /* init main configuration */
- NULL, /* create server configuration */
- NULL, /* merge server configuration */
- NULL, /* create location configuration */
- NULL /* merge location configuration */
- };
- ngx_module_t ngx_http_neonginx_test_module = {
- NGX_MODULE_V1,
- &ngx_http_neonginx_test_module_ctx, /* module context */
- NULL, /* module directives */
- NGX_HTTP_MODULE, /* module type */
- NULL, /* init master */
- NULL, /* init module */
- NULL, /* init process */
- NULL, /* init thread */
- NULL, /* exit thread */
- NULL, /* exit process */
- NULL, /* exit master */
- NGX_MODULE_V1_PADDING
- };
- static ngx_int_t
- ngx_http_neonginx_test_handler(ngx_http_request_t *r)
- {
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "NEONGINXTEST");
- return NGX_DECLINED;
- }
- static ngx_int_t
- ngx_http_neonginx_test_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, ngx_http_core_module);
- h = ngx_array_push(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers); // (ATTUALMENTE USIAMO NGX_HTTP_LOG_PHASE INVECE CHE PREACCESS PERCHE PREACCESS HA UN BUG E NELLA LOCATION / VIENE CHIAMATA DUE VOLTE, ES PER IL CONTATORE DELLE RICHIESTE CONTA DOPPIO, O SE METTI QUALCOSA CHE LOGGA LOGGA DOPPIO), PER FARLA CHIAMARE APPENA LA RICHIESTA ARRIVA USARE NGX_HTTP_PREACCESS_PHASE INVECE CHE NGX_HTTP_LOG_PHASE
- if (h == NULL) {
- return NGX_ERROR;
- }
- *h = ngx_http_neonginx_test_handler;
- return NGX_OK;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement