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

How do I get nginx to ignore requests on http://127.0.0.1/ but hand out from my html directory on http://127.0.0.1/somename this will also need to be the same for the proxy for /data/


I have tried the below and only get a 404.

server {
    listen       80;
    server_name  localhost;

    location / {
        #Do I need something in here regardless?
    }

    location /somename {
        root   ../html;
        index  index.html index.htm;
    }


    #reverse proxy for ie support
    #
    location /somename/data {
        proxy_pass  http://localhost:8080/data/;
        proxy_set_header  host localhost;
    }

    # redirect error pages to the static pages /50x.html /40x.html
    error_page  404              /404.html;
    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
        root   ../html;
    }

    location = /404.html {
        root   ../html;
    }

}
share|improve this question

2 Answers 2

up vote 2 down vote accepted
location / {
    return 404;
}

location /somename/ {
    alias  ../html/;
    index  index.html index.htm;
}
share|improve this answer

What do you mean by "ignore"? If you access http://127.0.0.1/, what behaviour do you want?

I think it reasonable that you get a 404 if you access a path for which your web server does not have a file to send back to the client.

share|improve this answer
    
Ah correct a 404 would be fine. However I also get a 404 for http://127.0.0.1/somename with the above config for location /somename. If I set the same config for location / I get my home page as I would expect. –  Marrowmaw Jul 20 '12 at 10:57

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.