Nginx conf environment variables

Anonymous
HOBBY

7 months ago

Not exactly a railway specific question, but I was following the tutorial specific to railway here: https://www.youtube.com/watch?v=oitx514tQgk

I see that in his nginx.conf file, he hard codes the url of his two apis.

https://github.com/sidpalas/devops-directive-docker-course/blob/railway/05-example-web-application/client-react/nginx.conf

I would like to have this based off a variable, since I have multiple environments (dev, staging, prod). I am curious if anyone has any solid solutions for this. Nginx environment variables seem like a possible solution, but seem maybe overly complicated? Not sure if there is an easier solution. Thanks for any help.

Solved

0 Replies

7 months ago

one of the main reasons I dislike nginx is because there is no environment variable syntax, would you be opposed to using caddy instead?

otherwise you'll have to run the config file through a pre-processor


Anonymous
HOBBY

7 months ago

not opposed, i was just curious if there was a simple solution with nginx first. If you don't think there is, then I'll probably just look to copy your Caddy/React template 🙂


Anonymous
HOBBY

7 months ago


7 months ago

updated my my message above 🙂


Anonymous
HOBBY

7 months ago

reverse proxy is set up and seems to be working. Thanks for the template!


7 months ago

no problem!


7 months ago

!s


Status changed to Solved brody 7 months ago