Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit e25aaa41501c547aed62a4c74ae35635b1c97ac8 0 parents
@catap authored
Showing with 108 additions and 0 deletions.
  1. +1 −0  AUTHOR
  2. +3 −0  LICENCE
  3. +3 −0  config
  4. +101 −0 ngx_http_dump_config_module.c
1  AUTHOR
@@ -0,0 +1 @@
+Kirill A. Korinskiy <catap@catap.ru>
3  LICENCE
@@ -0,0 +1,3 @@
+Public Domain
+
+No warranty expressed or implied. Use at your own risk.
3  config
@@ -0,0 +1,3 @@
+ngx_addon_name=ngx_http_dump_config_module
+HTTP_MODULES="$HTTP_MODULES ngx_http_dump_config_module"
+NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_dump_config_module.c"
101 ngx_http_dump_config_module.c
@@ -0,0 +1,101 @@
+
+/*
+ * Copyright (C) Kirill A. Korinskiy
+ */
+
+#include <nginx.h>
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_http.h>
+
+static char *ngx_http_dump_config_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
+
+
+static ngx_command_t ngx_http_dump_config_commands[] = {
+
+ { ngx_string("dump_config"),
+ NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_NOARGS,
+ ngx_http_dump_config_set_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ ngx_null_command
+};
+
+
+static ngx_http_module_t ngx_http_dump_config_module_ctx = {
+ NULL, /* preconfiguration */
+ NULL, /* 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_dump_config_module = {
+ NGX_MODULE_V1,
+ &ngx_http_dump_config_module_ctx, /* module context */
+ ngx_http_dump_config_commands, /* 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_dump_config_handler(ngx_http_request_t *r)
+{
+ ngx_int_t rc;
+ ngx_buf_t *b;
+ ngx_chain_t out;
+
+ b = ngx_conf_dump((ngx_cycle_t *)ngx_cycle, r->pool);
+ if (b == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ out.buf = b;
+ out.next = NULL;
+
+ b->memory = 1;
+ b->last_buf = 1;
+
+ r->headers_out.status = NGX_HTTP_OK;
+ r->headers_out.content_length_n = b->last - b->pos;
+
+ rc = ngx_http_send_header(r);
+
+ if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
+ return rc;
+ }
+
+ return ngx_http_output_filter(r, &out);
+}
+
+
+static char *
+ngx_http_dump_config_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_http_core_loc_conf_t *clcf;
+
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
+
+ clcf->handler = ngx_http_dump_config_handler;
+
+ return NGX_CONF_OK;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.