Keith Rarick

Nginx-Notice

Nginx-notice is an nginx module designed to ignore the usual semantics of HTTP methods POST and PUT, treating those requests as if they were GET requests and returning a fixed response body regardless of the request URI. It’s intended to display notices of downtime to agents that sent POST requests even when they shouldn’t, such as the Facebook platform canvas page callbacks. This module was originally written for the Causes on Facebook application.

Requirements

  • Source code for nginx. I have tested this module with nginx version 0.5.24.

Source Code

Find it at https://github.com/kr/nginx-notice.

Configuration

Once the module is installed, you will have two new configuration directives.

Example Configuration:

server {
    if (-f /path/to/notice.txt) {
        rewrite ^(.*)$ /notice.txt;
        break;
    }

    location = /notice.txt {
        notice /path/to/notice.txt;
        notice_type text/plain;
        break;
    }
}

Directive notice:

syntax : notice path

default : None

context : location

Enables display of the maintenance notice for this location.

Directive notice_type:

syntax : notice_type type

default : text/html

context : location

Sets the content-type of the notice for this location.

Bugs

  • There is a hard limit on the size of the notice that this module will send, by default 100KiB. You can change the limit by editing the source file.
  • This module does not log errors.

Changes

June 21, 2007

  • Bug fix: close the notice file after reading it.

June 12, 2007

  • Initial release