0

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;
    }

}
sphvn
  • 245
  • 1
  • 2
  • 6

2 Answers2

2
location / {
    return 404;
}

location /somename/ {
    alias  ../html/;
    index  index.html index.htm;
}
VBart
  • 8,159
  • 3
  • 24
  • 25
1

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.

Zut
  • 121
  • 1
  • 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. – sphvn Jul 20 '12 at 10:57