Mastering Nginx

(Ron) #1

The NGINX HTTP Server


[ 128 ]

location / {

# any server-level errors for this host will be directed
# to a custom application handler
error_page 500 501 502 503 504 = @error_handler;

}

location /microsite {

# for any non-existent files under the /microsite URI,
# the client will be shown a foreign page
error_page 404 http://microsite.example.com/404.html;

}

# the named location containing the custom error handler
location @error_handler {

# we set the default type here to ensure the browser
# displays the error page correctly
default_type text/html;

proxy_pass http://127.0.0.1:8080;

}

}

}

Using limits to prevent abuse


We build and host websites because we want users to visit them. We want our


websites to always be available for legitimate access. This means that we may have
to take measures to limit access to abusive users. We may define "abusive" to mean


anything from one request per second to a number of connections from the same IP
address. Abuse can also take the form of a DDOS (distributed denial-of-service)


attack, where bots running on multiple machines around the world all try to access


the site as many times as possible at the same time. In this section, we will explore
methods to counter each type of abuse to ensure that our websites are available.

Free download pdf