Reputation: 41
Intro
My FastCGI servers are written in C. I would like the FCGI
auth server to pass some custom parameters (such as some parameters returned by a Radius server) to a FCGI "back-end"
server.
My Question
Does NGINX support passing custom parameters between two FCGI servers in C? If yes, I would appreciate some help on the following:
curent work
This is what I have. The FCGI /auth server would set the custom_param variable
, and I would like NGINX to forward this variable to the FCGI back-end server.
location / {
auth_request /auth;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
location = /auth {
include fastcgi_params;
fastcgi_param CUSTOM_PARAM custom_param;
fastcgi_pass 127.0.0.1:9010;
}
Thanks for your help!
Upvotes: 4
Views: 3379
Reputation: 4371
Authentication handlers pass information back to the server via http headers. With nginx you'll use auth_request_set
to assign those values to variables:
location / {
auth_request /auth;
auth_request_set $receive_from_auth $upstream_http_x_custom_param;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
Sending parameters to FCGI from nginx works the way you indicated:
location = /auth {
include fastcgi_params;
set $send_to_auth yourvalue;
fastcgi_param CUSTOM_PARAM $send_to_auth;
fastcgi_pass 127.0.0.1:9010;
}
And those parameters are read from the environment:
char *custom_param;
custom_param = getenv("CUSTOM_PARAM");
Upvotes: 2