Unable to see web statistics if nginx-only mod is enabled: 404 page not found

Created:

2017-02-17 13:45:19 UTC

Modified:

2017-08-16 17:17:14 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Unable to see web statistics if nginx-only mod is enabled: 404 page not found

Applicable to:

  • Plesk Onyx for Linux

Symptoms

Unable to see web statistics if nginx-only mode is enabled (nginx Proxy mode is disabled at Apache & nginx Settings > nginx settings ). "404 page not found" error is shown instead of webstatistics.

Cause

This is Plesk internal issue with id #PPPM-5778 . It has been fixed in Plesk Onyx 17.5

Resolution

Upgrade to the Plesk Onyx 17.5.

If upgrade is not possible, the actions below can be used as a workaround. Make sure that web statistics page protected by password for the domain and create a custom template:

  1. Check Protect access to your web statistics with your FTP username and password for domain at Subsriptions > example.com > Hosting Settings .

  2. Make sure that there is no such an existing custom template and create a new one:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/domain/service/
    # touch nginxProtectedDirectories.php
    
  3. Insert the following code into the created file:

    <?php foreach(($OPT['ssl'] ? $VAR->domain->protectedDirectories->sslDirectories : $VAR->domain->protectedDirectories->nonSslDirectories) as $directory): ?>
    location /<?php echo ltrim($directory['relativePath'] . '/', '/'); ?> {
    auth_basic "<?php echo 0 < strlen($directory['realm']) ? $directory['realm'] : ' '?>";
    auth_basic_user_file "<?php echo $directory['authFile'] ?>";
    alias "<?php echo $VAR->domain->physicalHosting->statisticsDir?>/";
    <?php if ($VAR->domain->physicalHosting->php && $VAR->domain->physicalHosting->proxySettings['nginxServePhp']): ?>
    location ~ \.php(/.*)?$ {
    <?php echo $VAR->includeTemplate('domain/service/fpm.php'); ?>
    }
    location ~ /$ {
    <?php echo $VAR->domain->physicalHosting->proxySettings['directoryIndex'] ?>
    }
    <?php endif; ?>
    }
    <?php endforeach; ?>
  4. Rebuild webserver configuration files to apply changes:

    # /usr/local/psa/admin/bin/httpdmng --reconfigure-all

    Warning! In case of a big number of hosted domains the command above can cause a significant downtime, execute it during maintenance time frame.

Have more questions? Submit a request
Please sign in to leave a comment.