In a discussion titled ‘How can I update the nginx config directly in discourse/docker ..?’, Ibrahim_salem seeks to add a new section to the nginx configuration inside a Discourse Docker setup — not necessarily for a /photos folder (which was a placeholder example), but out of curiosity and flexibility. merefield questions the need, noting Discourse already handles image uploads, but later offers a workaround: using replace hooks in app.yml to modify /etc/nginx/conf.d/discourse.conf by matching and appending to existing patterns as shown in a prior Let’s Encrypt guide [4]. Ibrahim_salem asks if there’s a dedicated ‘append’ instruction, but merefield suggests getting creative, proposing to match the end of the file and replace it with itself plus the new section [9]. Stephen encourages explaining the underlying need, which Ibrahim_salem reiterates is theoretical — he can work around the requirement, but wants to know how to directly insert a new nginx section if needed. Ultimately, Ibrahim_salem accepts the suggested pattern-matching approach, concluding no ‘magic’ append field exists.
inside the web template file, I found the instructions where it update the nginx config file template (replace statements) ..
Isn’t there away to add a whole new section to nginx config ???
/uploads folder in discourse/shared is accessible from nginx .. I want to add a new folder /photos ..
is there a direct way (discourse recommended way)
Maybe I have mentioned ther wrong example .. what I’m trying to figure out is .. how can I reach the origianl nginx config and add a whoe section inside whether adding a new mapping for a folder or anything else .. is that doable ? or it’s just not recommended ?
I can install an external nginx server and make it redirect all links to the docker nginx and do my stuff ..
We also need to remove the additional rewrite that web.ssl.template.yml adds since it forces only the DISCOURSE_HOSTNAME and now we have others!
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /gzip on;[^\}]+\}/m
to: |
gzip on;
add_header Strict-Transport-Security 'max-age=31536000'; # remember the certificate for a year and automatically connect to HTTPS for this domain
Why not tell us why you need this extra folder? It’s possible that someone else has had a similar need, but that the assumed solution isn’t the only way to achieve it.
I said it was a bad example .. I can manage any extra folder with different solutions .. no issues so far ..
Yet, I want to be able to add a whole new section in the nginx config .. I’m just curios how to do it if I had to do it ..
Any chance you could pattern match as I proposed, the match being the pattern at the end of the file, then replace the pattern with the same but with your changes added onto the end?
I thought so ..
I was wondering maybe there is a mahic field for newly appended section .. defined for this purpose ..
never mind .. I think I can manage based on your suggestion