If you are not using ea-NGINX, and have manually installed NGINX outside of cPanel, you may find that Apache has stopped logging access logs. This is because when using ea-NGINX, Apache access logs are no longer written.
If you are using an unsupported version of NGINX and you would like for Apache to keep logging requests, you can use the following procedure to re-enable Apache's access logs.
NOTE: This resource is provided as a courtesy. NGINX installations that are not provided directly by cPanel are not supported by cPanel. If the following procedure does not resolve your issue with your unsupported version of NGINX, you must reach out to a systems administrator that has the skills, training, and expertise required to investigate and resolve the issue with your custom NGINX installation.
NOTE: cPanel is currently working on implementing a supported version of NGINX. Details for installing and using our experimental version of NGINX can be found here:
- Login to WHM as the root user
- Navigate to: Home »Service Configuration »Apache Configuration
- Click on the "Include Editor"
- Select "All Versions" from the dropdown under the "Pre VirtualHost Include" section
- Enter the following into the text area:
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" !isproxyrequest
- Click the blue Update button
- Allow time for logs to be written
- Run the following script to manually update the stats for AWStats and Webalizer if you would like to have the stats generated without waiting for the automatic generation to occur:
You may also just run status for a single user at a time if you prefer
How does this workaround work?
The above workaround works by overriding the isproxyrequest variable that is set earlier in the Apache configuration.
The isproxyrequest variable is set by the following line to detect if NGINX is sending the request:
grep isproxyrequest /etc/apache2/conf/httpd.conf | head -1
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" isproxyrequest
Notice that there is a single difference between the default configuration and the configuration that you add as the workaround. That is the ! operator. When you add the workaround it overwrites the existing configuration and sets the variable to the opposite value, which then tells Apache to log requests to the access log.