name based hosting limiting

Igor Sysoev is at rambler-co.ru
Tue Sep 2 23:39:19 MSD 2008


On Tue, Sep 02, 2008 at 03:27:44PM -0400, Paul wrote:

> Is there a way to limit the domains that can be requested on a server 
> directive?
> 
> Say I have
> 
>    server
>        {
>                listen 2.2.2.2:80;
>                server_name x.com *.x.com;
>                location /
>                {
>                        proxy_pass http://1.1.1.1;
>                        proxy_redirect http://1.1.1.1/     
> http://$http_host/;
>                        proxy_redirect default;
>                        proxy_set_header        Host            
> $host;          ##Forwards host along
>                        proxy_set_header        X-Forwarded-For 
> $remote_addr;   ##Sends realip to customer svr
>                }
>        }
> 
> 
> 
> Can I say, ONLY x.com and *.x.com can use this server?  Because I can 
> send any domain to it  and it passes it along to the backend server.
> I would like to limit access to this.

     server {
         listen 2.2.2.2:80 default;
         server_name  _;
         return 404;
     }

     server {
         listen 2.2.2.2:80;
         server_name  x.com *.x.com;

         # you may also add possibility to use IP only in browsers
         # and no Host header at all using:
         #server_name  2.2.2.2  "";

         ...
     }

Look also http://marc.info/?l=nginx&m=122025301723208&w=2


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list