Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Re: How do I let linux assign the port that nginx listens on?

$
0
0
The point of having nginx in any kind of scenario is to be able to talk to it, so even if this should have to be a random port, you would like to know which one it is.

Therefore, you're free to have a script determining a random port in a given range, e.g,. between 8000/tcp and 8999/tcp, and substitute that with a bit of sed in your nginx.conf.template to produce an actual nginx.conf (or some sub-configuration for a server).

You may want to apply the same mechanism (maybe based on an envsubst) to change certificates, domain names, etc., based on the type of environment you're deploying to. I use that under Terraform to deploy nginx instances depending on the target environment's parameters.

--j.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>