Question on Instance structure.

Sergey A. Osokin osa at freebsd.org.ru
Thu Oct 27 20:37:08 UTC 2022


Hi Jon,

hope you're doing well.

On Thu, Oct 27, 2022 at 05:05:32PM +0000, jonmcalexander--- via nginx wrote:
> I have a question regarding structure.
> 
> What is the proper configuration of NGINX instances when you want to
> have multiple configurations of NGINX, but only 1 set of binaries?

I'd recommend to take a look on how it's organized in www/nginx-devel [1]
in FreeBSD ports tree [2].  The management script [3] of that port
supports profiles, so it's possible to run several instances of nginx on
the same box.

1. Enable nginx in /etc/rc.conf:
nginx_enable="YES"

2. Specify needful profiles in /etc/rc.conf, i.e.
nginx_profiles="1 2 3 4 5"

3. Add lines with configuration files:
nginx_1_configfile="/usr/local/etc/nginx/nginx.conf.1"
nginx_2_configfile="/usr/local/etc/nginx/nginx.conf.2"
nginx_3_configfile="/usr/local/etc/nginx/nginx.conf.3"
nginx_4_configfile="/usr/local/etc/nginx/nginx.conf.4"
nginx_5_configfile="/usr/local/etc/nginx/nginx.conf.5"

4. Here's an example of the /usr/local/etc/nginx/nginx.conf.1 file:

worker_processes  1;

error_log  /var/log/nginx-error.log  debug;

events {
    worker_connections  10240;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    keepalive_timeout  65;
    include /usr/local/etc/nginx/conf.d.1/http_*.conf;
}


Refereces
---------
1. https://cgit.freebsd.org/ports/tree/www/nginx-devel/
2. https://www.freebsd.org/ports/
3. https://cgit.freebsd.org/ports/tree/www/nginx-devel/files/nginx.in

Hope that helps.
Thank you.

-- 
Sergey A. Osokin



More information about the nginx mailing list