簡體   English   中英

nginx位置別名:忽略靜態文件?

[英]nginx location alias: static files ignored?

我試圖讓zabbix-frontend與nginx一起工作。 這是我的nginx conf:

server {

    listen 80;
    server_name localhost;
    root /var/www/test/htdocs;
    index index.php index.html index.htm;


    location /zabbix {

        alias                   /usr/share/zabbix;
        index                   index.php;
        error_page              403 404 502 503 504  /zabbix/index.php;

        location ~ \.php$ {
            if (!-f $request_filename) { return 404; }
            expires                 epoch;
            include                 /etc/nginx/fastcgi_params;
            fastcgi_index   index.php;
            fastcgi_pass    unix:/var/run/php5-fpm.sock;
        }

        location ~ \.(jpg|jpeg|gif|png|ico)$ {
            access_log      off;
            expires         33d;
        }

    }


    location / {
            try_files $uri $uri/ /index.php;
            include /etc/nginx/proxy_params;
    }

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_read_timeout 120;
            include /etc/nginx/fastcgi_params;
    }

    include /etc/nginx/security;
    include /etc/nginx/main_rules;

}

/ zabbix中php腳本正在運行 但是沒有提供像/usr/share/zabbix/css.css這樣的文件(404)。 在錯誤日志中是這樣的:

2013/07/19 20:23:33 [error] 13583#0: *1 open() "/var/www/test/htdocs/zabbix/css.css" failed (2: No such file or directory), client: xxx, server: localhost, request: "GET /zabbix/css.css HTTP/1.1"

我們可以看到,nginx正在主根目錄/var/www/test/htdocs/尋找文件,而不是在別名目錄/usr/share/zabbix/

為什么會如此,我該如何解決?

我會嘗試將它們分開。 / zabbix只有別名和〜^ / zabbix / * .php $ with fastcgi。 兩者都位於/根位置之外。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM