0

I'm trying to make Nginx serve Cacti (a php monitoring app) from a subdomain, using the following configuration:

  server {
    listen 80;
    server_name cacti.mydomain.net;
    return 301 https://$server_name$request_uri;
  }

  server {
    listen 443 ssl;
    server_name cacti.mydomain.net;
    root /usr/share/webapps/cacti;

    index index.php;
    charset utf-8;

    location ~ \.php?$ {
      include /etc/nginx/fastcgi_params;
      fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    access_log /var/log/nginx/cacti.access.log main;
    error_log /var/log/nginx/cacti.error.log warn;

    include ssl.conf;
  }

However, when I go to https://cacti.mydomain.net/, Nginx returns a 404. The error log shows lines like this one:

[error] 41809#41809: *26 open() "/usr/share/webapps/cacti/cacti/include/themes/modern/images/cacti_logo.gif" failed (2: No such file or directory), client: 83.162.2.169, server: cacti.mydomain.net, request: "GET /cacti/include/themes/modern/images/cacti_logo.gif HTTP/2.0"

It looks like the request is going where the file is, but it tries to open it from the wrong place (cacti/cacti/include/...)

I've tried different location blocks, but that changes the url to https://cacti.mydomain.net/cacti/ which is not what I want. Can someone tell me what I'm missing here? Thanks for any help!

Mr. Wrong
  • 101
  • 2
  • 1
    It seems that the application expects to access its resources by prefixing `/cacti/` to the URI. If you want to change that, you will need to look at the application and not Nginx. If you want `/` to redirect to `/catci/` then add `location = / { return 301 /cacti/; }` – Richard Smith Feb 04 '19 at 13:11

1 Answers1

0

The configuration in /usr/share/webapps/cacti/include/config.php appeared to contain this line:

$url_path = '/cacti/';

Replacing the value with a slash solved the problem.

Mr. Wrong
  • 101
  • 2