Custom error page for post queries

Keferoff nginx-forum at
Mon Aug 11 07:39:40 UTC 2014


Current infrastructure:
We have nginx/1.7.1 as frontend for java application. We have special
requirement, when java app goes down we need response with 204 error code
instead 500 or 502 and this works like in charm for GET queries but nit for

The question:
How I need ti change my config for POST queries.

The nginx.conf

upstream rtb {
  keepalive 32;
  server fail_timeout=0;

server {

  open_file_cache          max=1000 inactive=20s;
  open_file_cache_valid    30s;
  open_file_cache_min_uses 2;
  open_file_cache_errors   on;

  log_not_found off;
  access_log    off;
  error_log     /var/log/nginx/error.log warn;

  error_page 502 500 =204 @maintenance;
  location @maintenance {
    try_files $uri $uri/ /204/204.html =204;

  location / {
    try_files $uri @rtb;

  location @rtb {
    access_log /var/log/nginx/rtb.access.log;

    proxy_set_header        Host                    $host;
    proxy_set_header        HTTP_HOST               $host;
    proxy_set_header        X-Real-IP               $remote_addr;
    proxy_set_header        X-Forwarded-For        
    proxy_set_header        HTTP_X_FORWARDED_PROTO  $scheme;
    proxy_set_header        X-Forwarded-Proto       $scheme;

    proxy_redirect off;
    proxy_max_temp_file_size 0;

    proxy_pass http://rtb;

Thanks in advance!

Posted at Nginx Forum:,252477,252477#msg-252477

More information about the nginx mailing list