0

I have an SSL domain that runs nginx, and I want to be able to access my munin graphs/stats on that domain. So, in the domain's server block, I added this:

    location = /munin/ {
            alias /var/cache/munin/www/;
    }

Theoretically, I should be able to go to http://example.com/munin and be shown /var/cache/munin/www/index.html. However, I get a 500 error, and this message in error.log:

2011/08/26 15:21:25 [error] 19089#0: *31218 rewrite or internal redirection cycle while internal redirect to "/index.html", client: 1.2.3.4, server: domain.com, request: "GET /munin/ HTTP/1.1", host: "domain.com"

I've tried a bunch of different things, but nothing seems to work. I'd be really grateful if somebody could shed some light on this situation, and maybe come up with a solution. Thanks! :)

Here is the full configuration for the domain, if it helps:

server {

        listen 443 default ssl; ## listen for ipv6
        ssl_certificate         somewhere;
        ssl_certificate_key     somewhere;

        root /srv/www/domain.com/wwwroot;
        index index.html index.htm index.php;
        access_log /srv/www/domain.com/logs/access.log combined;
        error_log /srv/www/domain.com/logs/error.log;

        server_name example.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.html;
        }

        error_page 404 /404.html;
        error_page 403 /403.html;

        # redirect server error pages to the static page /50x.html

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/www;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        location ~ \.php$ {
                fastcgi_param HTTPS on;
                include fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one

        location ~ /\.ht {
                deny all;
        }

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location = /munin/ {
                alias /var/cache/munin/www/;
        }
}

server {

        listen [::]:80; ## listen for ipv6
        server_name example.com;
        rewrite ^(.*) https://domain.com$1 permanent;
}
womble
  • 96,255
  • 29
  • 175
  • 230
squircle
  • 524
  • 6
  • 14

1 Answers1

2

Why are you using location =? I'm fairly certain that isn't what you want. On the other hand, that shouldn't be causing your redirect loop, as I understand it, but it certainly won't be helping you get what you want. Enable nginx debugging (error_log ... debug or error_log ... debug_http if you've got an nginx built correctly) to see what nginx is doing to your request internally, and it should give you a clue as to how to fix it.

womble
  • 96,255
  • 29
  • 175
  • 230
  • On your advice, I changed it to `location ^~ /munin/`, but I'm still getting the redirect loop. I'll enable debugging and see what happens – squircle Aug 27 '11 at 01:48
  • Whoops; forgot to reload the configuration. Thanks for the fix! :) – squircle Aug 27 '11 at 01:58
  • 2
    No, `location ^~ /munin/` is wrong too. A straight `location /munin` will work just fine. – womble Aug 27 '11 at 03:21