title: Nginx Module Code error_page directive problems
body: <p>I am leveraging the ModSecurity WAF to help block tx's deemed dangerous on NGINX:
  <a href="https://github.com/SpiderLabs/ModSecurity" rel="nofollow noreferrer">https://github.com/SpiderLabs/ModSecurity</a>
  <a href="https://github.com/SpiderLabs/ModSecurity-nginx" rel="nofollow noreferrer">https://github.com/SpiderLabs/ModSecurity-nginx</a></p>
  
  <p>My issue can be found here:
  <a href="https://github.com/SpiderLabs/ModSecurity-nginx/issues/182" rel="nofollow noreferrer">https://github.com/SpiderLabs/ModSecurity-nginx/issues/182</a></p>
  
  <p>The TLDR of my problem is the nginx <code>error_page</code> directive resets the HTTP Request Method Header sent by the originating client during its redirect to GET. This causes false positive logs with the WAF to report client sent an HTTP Body with GET etc. when they really sent a POST and NGINX hits the <code>error_page</code> redirect due to some case with the upstream timing out on a reverse proxy call.</p>
  
  <p>To fix this I need to hack in or PR something to this file section seemingly:
  <a href="https://github.com/SpiderLabs/ModSecurity-nginx/blob/master/src/ngx_http_modsecurity_rewrite.c#L145" rel="nofollow noreferrer">https://github.com/SpiderLabs/ModSecurity-nginx/blob/master/src/ngx_http_modsecurity_rewrite.c#L145</a></p>
  
  <p>With the goal of something like this in sudo code:</p>
  
  <pre><code>//SAFE to trust this value as its the originating client HTTP REQUEST Method HEADER when not error_page
  if(!r-&gt;error_page){
     const char *n_method = ngx_str_to_char(r-&gt;method_name, r-&gt;pool);
    //HOW to add a transaction persistent context value here to store STORED_CTX_HTTP_REQUEST_METHOD_HEADER_VALUE???
  }
  else {  //IF ERROR_PAGE, then we need to grab the original stored CTX request http method header value.
    const char *n_method = ngx_str_to_char(STORED_CTX_HTTP_REQUEST_METHOD_HEADER_VALUE); 
  }
  </code></pre>
  
  <p>And it is here that I have been unable to solve the above sudo code. How does one create a tx context safe variable here that can persist across the phases and internal <code>error_page</code> redirect to store the original client http method header? </p>
  
  <p>I landed on these NGINX page guides but so far no dice really seeing anything cutting into what I want:
  <a href="https://www.evanmiller.org/nginx-modules-guide.html" rel="nofollow noreferrer">https://www.evanmiller.org/nginx-modules-guide.html</a></p>
  
  <p>Looking for any NGINX / C guru's that understand the issue and might be able to turn my sudo code into something I can test in my sandbox environment.</p>
  
  <p>Note I don't have the luxury of doing away with my NGINX error_page directive calls. So I do need a solution to the above sudo code I believe.</p>
  
  <p>Thanks!</p>