【问题标题】:nagvis & nginx configuration: url redirect without location namenagvis 和 nginx 配置:没有位置名称的 url 重定向
【发布时间】:2015-09-17 00:25:47
【问题描述】:

我正在尝试让 nagvis (http://www.nagvis.org/) 与 nginx 一起工作。不幸的是我做不到...

我已经有一个服务器和其他几个位置,我想为 nagvis 添加一个新的。这是我的尝试之一:

server{
    listen   443 ssl;

    root /apps/www/admin;
    index index.php;

    ssl_certificate /apps/ssl/admin.chained.crt;
    ssl_certificate_key /apps/ssl/admin.key;


    server_name admin admin.mycompany.fr;

    #auth ldap through pam
    auth_pam        "Admin Zone";
    auth_pam_service_name "admin_nginx";

    location ^~ / {
            index index.php;
            include /apps/etc/nginx/php.conf;

    location ^~ /nagvis {
                root /usr/share/nagvis/share;
                index index.php;
                include /apps/etc/nginx/php.conf;
                try_files $uri $uri/ /index.php;
        }

   location ^~ /phpmyadmin {
                root /usr/share;
                index index.php;
                include /apps/etc/nginx/php.conf;

                try_files $uri $uri/ /index.php;

当我尝试使用此配置“https://admin.soc.mycompany.fr/nagvis/index.php”时,我得到:

==> /var/log/nginx/error.log <==
2015/06/30 11:14:11 [error] 10568#10568: *185 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nagvis/share/nagvis/frontend/nagvis-js/index.php (No such file or directory)" while reading response header from upstream, client: 172.20.0.5, server: admin, request: "GET /nagvis/frontend/nagvis-js/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "admin.mycompany.fr"

==> /var/log/nginx/access.log <==
172.20.0.5 - lagarjoc [30/Jun/2015:11:14:11 +0200] "GET /nagvis/frontend/nagvis-js/index.php HTTP/1.1" 404 56 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36"

/usr/share/nagvis/share 中的第一个 index.php 是重定向到“/frontend/nagvis-js/index.php”。它运行良好并被重定向到https://admin.mycompany.fr/nagvis/frontend/nagvis-js/index.php

但 nginx 本身正在“/usr/share/nagvis/share/nagvis/frontend/nagvis-js/index.php”中寻找文件,而不是 “/usr/share/nagvis/share/frontend/nagvis-js/index.php”(位置太多了)。

我希望我说得够清楚,希望你能帮助我。

提前谢谢,我卡住了:(

【问题讨论】:

    标签: redirect nginx nagios


    【解决方案1】:

    好吧,我找到了一个“hack”来让它工作。

    我只是像这样添加了一个符号链接:

    ln -s /usr/share/nagvis/share /usr/share/nagvis/share/nagvis
    

    我想知道我是否可以直接通过 nginx 配置避免该问题,但至少目前可以找到这项工作!

    希望它也会对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 2016-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-20
      • 2019-01-28
      • 1970-01-01
      • 1970-01-01
      • 2018-02-22
      相关资源
      最近更新 更多