Help Center/ Application Operations Management/ FAQs (2.0)/ Collection Management/ How Do I Enable the Nginx stub_status Module?
Updated on 2025-02-12 GMT+08:00

How Do I Enable the Nginx stub_status Module?

Nginx Prometheus Exporter monitors the Nginx service using the stub_status module. Ensure that this module is enabled. Perform the following operations:
  1. Log in to the node where the Nginx service is deployed and run the following command (generally in the /usr/local/nginx/sbin/nginx directory) as the root user to check whether the stub_status module is enabled:
    nginx -V 2>&1 | grep -o with-http_stub_status_module
    • If with-http_stub_status_module is returned, the stub_status module is enabled.
    • If no result is returned, enable the stub_status module by setting --with-http_stub_status_module in the configuration file. Example:
      ./configure \
      ## Add the --with-http_stub_status_module parameter.
      --with-http_stub_status_module
      make
      sudo make install
  2. After the stub_status module is enabled, add the following content to the nginx.conf file (which is generally in the /usr/local/nginx/conf directory): Example:
    1. Open the nginx.conf file using the vi editor:
      vi /usr/local/nginx/conf/nginx.conf
    2. Press i to enter the editing mode and add the following configuration information:
      server {
       listen 8080;  # Listening port. Set this parameter based on service requirements.
       listen [::]:8080; # IPv6 listening port. Set this parameter based on service requirements.
       server_name localhost; # Set this parameter based on service requirements.
       location = /stub_status { # Path. Set this parameter based on service requirements.
           stub_status on;
           access_log off;
           allow 127.0.0.1;
       }
      }
    3. Press Esc and enter :wq to save the settings and exit.
  3. Restart the Nginx service.