Custom error page for post queries

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


Hi!

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
POST. 

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

The nginx.conf

upstream rtb {
  keepalive 32;
  server 127.0.0.1:8085 fail_timeout=0;
}


server {
  server_name  rtb.loopme.me;

  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_add_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: http://forum.nginx.org/read.php?2,252477,252477#msg-252477



More information about the nginx mailing list