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
This can be done by establishing the listening port external to nginX and then using the "NGINX" environment variable to pass the file descriptor to nginX, e.g.:

NGINX="3;" nginx

You need to specify the "listen" clause(s) using the same address as was established for the listening port, e.g.:

http {
server {
listen [::]:53124;
}
}

Notes:

This mechanism is undocumented (quite deliberately, it would appear), but is widely used for systemd-based launches.

The use of the NGINX environment variable implies daemon=off.

One reason you might want to do this sort of thing is to be able to run a number of nginX instances in parallel to perform tests in isolation from each other.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



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