大网数据广告活动
服务器运维问答

Munin/Nginx - Nginx prepending root path to file despite different path specifed with alias

· 52CE 我爱测

I have installed munin (for the time being available here: http://brailsford.xyz/munin ) the problem is that whilst the core loads from /var/cache/munin/www - none o the static files load. I have the following in my nginx config:…

问题原文

原帖链接 · AviateX14 · CC BY-SA 3.0

I have installed munin (for the time being available here: http://brailsford.xyz/munin ) the problem is that whilst the core loads from /var/cache/munin/www - none o the static files load.

I have the following in my nginx config:

    location /munin/static/ {
            alias /etc/munin/static/;
            expires modified +1w;
            autoindex on;
    }

    location /munin/ {
            #auth_basic            "Restricted";
            # Create the htpasswd file with the htpasswd tool.
            #auth_basic_user_file  /etc/nginx/htpasswd;

            alias /var/cache/munin/www/;
            expires modified +310s;
    }

AutoIndex is there for a proof: the folder is accessible: https://brailsford.xyz/munin/static/

However, clicking on a file in that folder gives a 404, and the nginx error log shows this:

[error] 22570#0: *50 open() "/data/www/brailsford.xyz/munin/static/style-new.css" failed (2: No such file or directory)

/data/www/brailsford.xyz is my root specified in the overall server clause.

Any suggestions would be greatly appreciated :)

EDIT 1:

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff)$ {
            expires 1w;
    }

已采纳解答

原帖链接 · Richard Smith · CC BY-SA 3.0

The location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff)$ block takes precedence for any URIs which end with .css, which means that nginx tries to use the wrong value for root.

Use the ^~ modifier on the prefix location to make it take precedence over any regex location.

For example:

location ^~ /munin/static/ { 
    ...
}

This assumes that the location does not have any special content, such as .php files.

See this document for details.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。