Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I see this question was also asked here: Configure Nginx global error page but there wasn't a suitable answer.

I am currently allowing only certain IPs addresses to some of my sites and would like Nginx to drop connections from the rest of the IP addresses instead of returning a 403. Ideally, I would like to do this without configuring each site separately.

I have this in the http section:

error_page 403 =444;

But, now, it tries to serve up the page =444 instead of returning a 444.

share|improve this question
up vote 3 down vote accepted

So you can do a few things

error_page   403;

Or you can do something like

error_page 403 /403.html

location /403.html {
    root /some/path/that/has/file; 

for the 403.html would be in /some/path/that/has/file

share|improve this answer
I would have to add that location block to all of my server blocks, correct? I'm trying to avoid having to edit every one of the server blocks since there are so many. Thanks! – sidprak Apr 10 '12 at 20:42
if you do the location {} option yes.. if you do the one above it that can go in the http {} but I believe it redirects. – Mike Apr 10 '12 at 20:48
Ok, makes sense; thanks for the explanation. I can't get the second option to work, though. For some reason, Nginx tries to look for /some/path/that/has/file/403.html/index.html and then fails since 403.html is not a directory. Any suggestions? – sidprak Apr 10 '12 at 20:50
edit your post and show that part of the config – Mike Apr 10 '12 at 22:23
I just did more research and, originally I was trying to return a blank page to achieve the result, but I found I can return a 444. Now my question becomes, how do I return a 444 when an IP address is denied? – sidprak Apr 10 '12 at 22:38

Your Answer


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.