Welcome! Log In Create A New Profile

Advanced

sending POSTs to backend

September 18, 2013 06:17AM
Hello folks,

I use nginx in front of a django/fastcgi application, and we serve a subset of the URLs of this webapp statically.

I use try_files to determine what's served statically and what goes to the backend.

Some of these URLs, however, contain forms and are at the same time source and targets for them. The former can be served statically, while the latter should hit the backend.

A simple "if ($request_method) { directive; }" would work, but I find no effective "directive" to send the request to the backend.

Our basic setup looks like this:

server {
root /site/static_files/;
try_files $uri $uri/ $uri/index.html @appsrv;

if ($request_method = POST) {
# solution 1: try_files /var/emtpy/.foobar @appsrv
# solution 2: fastcgi_pass 1.2.3.4:1234;
# all of the above fail: directive not allowed here
# solution 3: return 321; (+ define error_page 321 in server {})
# I can't get the above handle correctly good and bad responses from the appsrv
}

location @appsrv {
include /usr/local/etc/nginx/fastcgi_params_django;
fastcgi_pass 1.2.3.4:1234;
}
}

any suggestion to divert POST requests to the given named location?

cheers
michele
Subject Author Posted

sending POSTs to backend

michelem September 18, 2013 06:17AM

Re: sending POSTs to backend

Maxim Dounin September 18, 2013 10:24AM

Re: sending POSTs to backend

michelem February 13, 2014 04:08PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready