Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This was really annoying and now i see when it happens. If <ip>/NAME exist in /var/www (/var/www/NAME) nginx will give me a redirect to www._.com/NAME/ (note the slash and lack of url) which is annoying and just wrong. If the url ends with a / it will check the index and serve index.html

How do i either make it give me an error page or add a / to the end of it?

server {

    listen   80; ## listen for ipv4
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    server_name  _;

    access_log  /var/log/nginx/localhost.access.log;
    root   /var/www;

    location / {
        root   /var/www;
        index  index.php index.html index.htm;
    }

    location /doc {
        root   /usr/share;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }

    location /images {
        root   /usr/share;
        autoindex on;
    }

}
share|improve this question
    
Is there any include directive in your main configuration file? –  quanta Sep 27 '11 at 5:39

1 Answer 1

server_name_in_redirect off; will tell nginx to use the request's Host: header instead of the first server_name argument when generating redirects.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.