title: Nginx "add before body" / "add after body" but only on content types
body: <p>Okay, I have a nginx config and location. I would like to add some html above and below the body, but only on html pages, so I would like to do <em>something</em> like this:</p>
  
  <pre><code>location / {
      proxy_pass http://internal.upstreamserver
  
      if $response_header == "text/html" {
  
          add_before_body /statics/before.html;
          add_after_body /statics/after.html;
      }
  }
  </code></pre>
  
  <p>My understanding is that I can't use an if because it executes at the wrong point of the cycle, and some modules do tie into the rewrite step, so whats the module to look into / use ? (I am using the nginx-python mod for other access-control elements, but this doesn't have a hook into the rewrite stage, and I don't have the C abilities or nginx knowledge to patch that feature in :S) </p>