<div dir="ltr">Thanks for the fast reply!<div><br></div><div>So I think I see how this works now; however, I'm getting a new error.  Seems to be parsing related.  Here is what I have now:</div><div><br></div><div>  #define NGX_MY_CUSTOM_MODULE_CONF 0x80000001</div><div><br></div><div><div style="font-size:12.8px">  static ngx_command_t ngx_my_custom_module_commands[<wbr>] = {                                 </div><div style="font-size:12.8px">      {                                                                                </div><div style="font-size:12.8px">        ngx_string("my_custom_module_<wbr>block"), /* directive */                                    </div><div style="font-size:12.8px">        NGX_HTTP_SRV_CONF |                                                            </div><div style="font-size:12.8px">        NGX_HTTP_LOC_CONF |                                                            </div><div style="font-size:12.8px">        NGX_CONF_NOARGS |                                                              </div><div style="font-size:12.8px">        NGX_CONF_BLOCK,                                                                </div><div style="font-size:12.8px">        my_custom_module_block, /* configuration setup function */                     </div><div style="font-size:12.8px">        0, /* No offset. Only one context is supported. */                             </div><div style="font-size:12.8px">        0, /* No offset when storing the module configuration on struct. */            </div><div style="font-size:12.8px">        NULL                                                                           </div><div style="font-size:12.8px">      },                                                                               </div><div style="font-size:12.8px">                                                                                      </div><div style="font-size:12.8px">     {                                                                                </div><div style="font-size:12.8px">        ngx_string("directive_for_my_<wbr>custom_module_block"), /* directive */                                      </div><div style="font-size:12.8px">        NGX_CONF_TAKE1|<span style="font-size:small">NGX_MY_CUSTOM_MODULE_CONF</span><span style="font-size:12.8px">,                                                                </span></div><div style="font-size:12.8px">        ngx_directive_for_my_custom_<wbr>module_block_cmd, /* configuration setup function */                         </div><div style="font-size:12.8px">        0, /* No offset. Only one context is supported. */                             </div><div style="font-size:12.8px">        0, /* No offset when storing the module configuration on struct. */            </div><div style="font-size:12.8px">        NULL                                                                           </div><div style="font-size:12.8px">     },                                                                               </div><div style="font-size:12.8px">                                                                                      </div><div style="font-size:12.8px">      ngx_null_command /* command termination */                                       </div><div style="font-size:12.8px">  };  </div></div><div><br></div><div><div>  static char *<span style="font-size:12.8px">my_custom_module_block</span>(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)  </div><div>  {                                                                                    </div><div>      cf->cmd_type = NGX_MY_CUSTOM_MODULE_CONF;                                            </div><div>      ngx_http_core_loc_conf_t *clcf;                                                  </div><div>      clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);              </div><div>      clcf->handler = ngx_my_custom_module_handler;                                        </div><div>      return NGX_CONF_OK;                                                              </div><div>  }</div></div><div><br></div><div><br></div><div>How I'm seeing the following error:</div><div><br></div><div><div>2017/06/28 21:48:46 [emerg] 1#1: "location" directive is not allowed here in /etc/nginx/nginx.conf:26</div><div>nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:26</div></div><div><br></div><div>Here is my full configuration file:</div><div><br></div><div><div>worker_processes  1;</div><div><br></div><div>load_module "modules/ngx_my_custom_module.so";</div><div><br></div><div>events {</div><div>    worker_connections  1024;</div><div>}</div><div><br></div><div>http {</div><div>    include       mime.types;</div><div>    default_type  application/octet-stream;</div><div><br></div><div>    sendfile        on;</div><div>    keepalive_timeout  65;</div><div>    server {</div><div>        listen       80;</div><div>        server_name  localhost;</div><div><br></div><div>        location / {</div><div><div style="font-size:12.8px">          my_custom_module_block {</div><div style="font-size:12.8px">            directive_for_my_custom_<wbr>module_block "Some value";<br>          }</div></div><div>        }</div><div><br></div><div>        error_page   500 502 503 504  /50x.html;</div><div>        location = /50x.html {</div><div>            root   html;</div><div>        }</div><div>    }</div><div>}</div></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 28, 2017 at 2:38 PM, Vladimir Homutov <span dir="ltr"><<a href="mailto:vl@nginx.com" target="_blank">vl@nginx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 29.06.2017 00:15, Joseph Spencer wrote:<br>
> Hello,<br>
><br>
> I'm trying to support this in my nginx.conf:<br>
><br>
> my_custom_module_block {<br>
>   directive_for_my_custom_<wbr>module_block "Some value";<br>
> }<br>
><br>
> Here is how I'm setting up the commands:<br>
><br>
>   static ngx_command_t ngx_my_custom_module_commands[<wbr>] = {<br>
><br>
>       {<br>
><br>
>        ngx_string("my_custom_module_<wbr>block"), /* directive */<br>
><br>
>         NGX_HTTP_SRV_CONF |<br>
><br>
>         NGX_HTTP_LOC_CONF |<br>
><br>
>         NGX_CONF_NOARGS |<br>
><br>
>         NGX_CONF_BLOCK,<br>
><br>
>         my_custom_module_block, /* configuration setup function */<br>
><br>
>         0, /* No offset. Only one context is supported. */<br>
><br>
>         0, /* No offset when storing the module configuration on struct.<br>
> */<br>
>         NULL<br>
><br>
>       },<br>
><br>
><br>
><br>
>      {<br>
><br>
>         ngx_string("directive_for_my_<wbr>custom_module_block"), /* directive<br>
> */<br>
>         NGX_CONF_TAKE1,<br>
><br>
>         ngx_directive_for_my_custom_<wbr>module_block_cmd, /* configuration<br>
> setup function */<br>
>         0, /* No offset. Only one context is supported. */<br>
><br>
>         0, /* No offset when storing the module configuration on struct.<br>
> */<br>
>         NULL<br>
><br>
>      },<br>
><br>
><br>
><br>
>       ngx_null_command /* command termination */<br>
><br>
>   };<br>
><br>
> Everything compiles fine; however, I receive the following error and<br>
> nginx won't start:<br>
><br>
> 2017/06/28 21:02:44 [emerg] 1#1: "directive_for_my_custom_<wbr>module_block"<br>
> directive is not allowed here in /etc/nginx/nginx.conf:19<br>
> nginx: [emerg] "directive_for_my_custom_<wbr>module_block" directive is not<br>
> allowed here in /etc/nginx/nginx.conf:19<br>
><br>
> If anyone could be of assistance I would greatly appreciate it.<br>
><br>
<br>
</div></div>Take a look at ngx_conf_file.h to understand which structure flags have.<br>
You did not specify any possible context for the command that will<br>
appear in your block: NGX_CONF_TAKE1 solo only describes number of<br>
arguments, but command is not matching anything, thus the error.<br>
<br>
You can either declare your own context, like ngx_http_upstream_module<br>
does (NGX_HTTP_UPS_CONF for commands inside upstream{} block) or<br>
use API from ngx_conf_file.h to process commands inside your block<br>
like ngx_conf_handler() does.<br>
<br>
<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Thanks,<div>Joe Spencer (member)</div><div>Kogo Software LLC</div></div></div>
</div>