Example configuration of NGINX Open Source

This article provides an example configuration for NGINX Open Source. If necessary, you can change the settings to suit your needs. This configuration was tested with package version 1.18.0-6ubuntu14.6.

To configure NGINX Open Source:

  1. On the host where you are installing the balancer, start the command line console and install the nginx-common package:

    sudo apt update && sudo apt install nginx-common -y

  2. Go to the /etc/nginx directory and edit the nginx.conf configuration file as shown in the example. The order of sections and parameters in the configuration file is significant and must be the same as in the example.

    Example of settings in the nginx.conf file if a TLS certificate is not used

    Example of settings in the nginx.conf file when using a TLS certificate

  3. Save the nginx.conf configuration file.
  4. Check the correctness of the nginx.cfg configuration file using the following command:

    sudo nginx -f /etc/nginx/nginx.conf -t

    If the check command returns an error, make sure the contents of the nginx.conf configuration file matches the example and make changes if necessary. If the check command does not return any errors, proceed to starting the balancer.

  5. Start the balancer:

    sudo systemctl start nginx

    If the nginx service needs to be enabled before starting, run the following sequence of commands:

    sudo systemctl enable nginx

    sudo systemctl start nginx

The balancer is configured.

Page top