Nginx 上的 Cacti 别名

Nginx 上的 Cacti 别名

我尝试在 Nginx 上以别名运行 Cacti,但是当我设置正确的别名路径时它返回 404。

奇怪的是,如果我设置另一个路径,它会加载文件。Cacti 路径/usr/share/cacti/site返回 404,如果我尝试,/usr/share/cacti我会得到一个包含目录的列表。

这是我的配置 -

server {
    #listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

    root /usr/share/nginx/www;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name domain.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.html;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            allow ::1;
            deny all;
    }

    location /cacti {
            autoindex on;
            alias /usr/share/cacti/site;
            index index.php index.html index.htm;
                    location ~ \.php$ {
                            try_files $uri =404;
                            fastcgi_pass unix:/var/run/php5-fpm.sock;
                            fastcgi_index index.php;
                            #fastcgi_param SCRIPT_FILENAME $document_root$request_filename;
                            include fastcgi_params;
                            fastcgi_param SCRIPT_FILENAME /usr/share$request_filename;
                    }
    }


}

答案1

尝试更改rootcacto 位置,我猜使用alias是导致 404 的根本原因,因为$document_root指的是root。我确信 error_log 包含更多线索。

相关内容