# Accept all server\_name's except empty

**URL:** <https://www.ruby-forum.com/t/accept-all-server-names-except-empty/212148>\
**Category:** NGINX\
**Created:** [September 23, 2011, 9:24am UTC](https://www.ruby-forum.com/t/accept-all-server-names-except-empty/212148 "2011-09-23T09:24:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [September 23, 2011, 9:24am UTC](https://www.ruby-forum.com/t/accept-all-server-names-except-empty/212148/1 "2011-09-23T09:24:39Z")

</div>

Dear all,

How can I set up my nginx configuration file so that it will accept all  
request; however it will deny if “host” header is not added?

Also currently I am logging bytes\_send per “host” and then take sum of  
them with a cron job monthly. Is there a better way to achieve this?

Cheers,  
Kaan Yamanyar

Posted at Nginx Forum:

> **[Accept all server\_name's except empty](https://forum.nginx.org/read.php?2,215685,215685#msg-215685)**
>
> Dear all, How can I set up my nginx configuration file so that it will accept all request; however it will deny if "host" header is not added? Also currently I am logging bytes\_send per "host" and then take sum of them with a cron...

---

<div class="post-metadata">

**Author:** ![yamanyar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ed655f/32.png) [@yamanyar](https://www.ruby-forum.com/u/yamanyar)\
**Post date:** [September 23, 2011, 9:48am UTC](https://www.ruby-forum.com/t/accept-all-server-names-except-empty/212148/2 "2011-09-23T09:48:46Z")

</div>

On Sep 23, 2011, at 11:24 , yamanyar wrote:

> Dear all,
> 
> How can I set up my nginx configuration file so that it will accept all  
> request; however it will deny if “host” header is not added?

server {  
server\_name “”; # no host header field in request  
return 444;  
}

server {  
server\_name \_;  
…  
}

> Also currently I am logging bytes\_send per “host” and then take sum of  
> them with a cron job monthly. Is there a better way to achieve this?

Currently no.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
