Discourse headless?

You can do the necessary mangling on your app.yml file.

The app.yml file you have now should be ending like this:

run:
  - exec: echo "Beginning of custom commands"
  ## blablabla
  - exec: echo "End of custom commands"

You can run replaces in the nginx file making it look like this

run:
  - exec: echo "Beginning of custom commands"
  ## blablabla
  - replace:
     filename: "/etc/nginx/conf.d/discourse.conf"
     from: "location @discourse {"
     to: |
       location @discourse {
       add_header AAA bbb;
  - exec: echo "End of custom commands"

There are several examples at discourse_docker/templates at master · discourse/discourse_docker · GitHub