Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Configuration for static contents 503 failover server

$
0
0
Hi Nginx users

I've created a cluster of servers that operates essentially as an overflow mechanism on load balancers. This cluster is added to physical load balancers with a lower priority, and in the event there is massive failure on the application servers, or exhaustion of connection limits, traffic will be directed to this cluster to say "Sorry, we're currently experiencing a problem, please check back later" (with a nice page, graphics, and CSS).

The reason for doing this with Nginx is for performance, and to permit application owners to customize the content of the page apologising for the service interruption. A CMS has been created behind the scenes that populates Nginx configuration based on a template, and places content into the required directories. This system currently serves about 1000 hostnames, and is expanding to at least 8 times that size in the next 6 months.

The current configuration isn't great. It's causing me problems as recently it was pointed out that POST/PUT requests are returning 405 errors instead of the custom content we've created.

Here is the configuration for an example host:

server {
listen 7003;
server_name graham-default-en.compmany.com;
root /htdocs/default-en/busy;

error_page 502 503 504 =503 @content;
error_page 405 /index.html;

location / {
try_files __force_503__.html =503;
}
location @content {
try_files $uri /index.html =404;
}
location /favicon.ico {
root /htdocs;
access_log off;
}
}

Here's some examples of requests and desired responses:

* GET / => 503 with content from root/index.html
* POST / => 503 with content from root/index.html
* PUT / => 503 with content from root/index.html
* GET /favicon.ico => 200 with content from root/favicon.ico

My trouble at the moment is getting this to accept a POST or PUT method, and either ignore it, or change it, to be able to send back a 503 with content. The GET requests are working OK.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>