passenger_set_cgi_params vs passenger_set_header vs passenger_set_env

88 views
Skip to first unread message

Alan Si

unread,
Apr 15, 2016, 1:50:10 PM4/15/16
to Phusion Passenger Discussions
Hi there,

I am updating an old system from passenger4 to passenger5 and pretty new to this topic. I've learned that passenger_set_cgi_params has been deprecated. However, I am not quite sure how to replace this with new options. Also, 

So could someone help me explain what is the difference among those three please?

Also, it looks like nginx has "proxy_set_header" that behaves similar. In what situation do we want to use passenger_* instead of "proxy_set_header"?

Thank you all in advance!

Daniel Knoppel

unread,
Apr 15, 2016, 2:32:14 PM4/15/16
to Phusion Passenger Discussions
Can you describe what you are trying to do in more detail? I'm assuming you've seen the documentation already and I'm not sure what to explain beyond that. You can just pass headers with passenger_set_header and read them in your app..?

Nginx' proxy_set_header is for use in conjunction with proxy_pass, so unless you've set that up it would be easier to use passenger_set_header.

- Daniel

Alan Si

unread,
Apr 15, 2016, 3:02:38 PM4/15/16
to Phusion Passenger Discussions
Hi Daniel,

Thank you for the help!

To clarify:

1. What is "passenger_set_cgi_params" was doing before? It seems phusion removed old docs and I couldn't find related info anywhere :(

2. For "passenger_set_env", for instance:

passenger_set_env: X_foo $something
I learned passenger_set_env is only working while application is loading. What does that mean? Will "X_foo" always be same value even though nginx passes different value to $something per request?

3. my understanding of others are as following, correct me if I am wrong

proxy_set_header: X_foo $something
Nginx add head "X_foo" with value $something to http request sending to passenger

passenger_set_header: X_foo $something
After receiving http request from nginx, prefix X_foo with HTTP_ and add the new header "Http_X_foo" with value $something to request and send it to rack

Daniel Knoppel

unread,
Apr 18, 2016, 5:37:06 AM4/18/16
to Phusion Passenger Discussions
1. What is "passenger_set_cgi_params" was doing before? It seems phusion removed old docs and I couldn't find related info anywhere :(

The SCGI protocol is used between Passenger and Rack apps, and with this option you could set a (per request) variable directly, e.g. X_FOO. In Passenger 5 we don't use SCGI everywhere anymore (e.g. not for Node.js apps) so we switched to the more generic HTTP header format in the config. 
 

2. For "passenger_set_env", for instance:

passenger_set_env: X_foo $something
I learned passenger_set_env is only working while application is loading. What does that mean? Will "X_foo" always be same value even though nginx passes different value to $something per request?

Yes, if you use set_env you'll keep getting the same value, very similar to how environment variables normally work.
 

3. my understanding of others are as following, correct me if I am wrong

proxy_set_header: X_foo $something
Nginx add head "X_foo" with value $something to http request sending to passenger

passenger_set_header: X_foo $something
After receiving http request from nginx, prefix X_foo with HTTP_ and add the new header "Http_X_foo" with value $something to request and send it to rack

Yes with a small correction: set_header must be in HTTP header format, so not underscores but dashes. For example: X-Foo. Underscores will be filtered for security reasons.

It will still be converted internally to an SCGI style header when the destination is a rack app, but with a HTTP_ prefix to avoid overwriting (so: set_header X-Foo --> in rack app read the value of HTTP_X_FOO), 

Hongli Lai

unread,
Apr 18, 2016, 5:58:19 AM4/18/16
to phusion-passenger
On Mon, Apr 18, 2016 at 11:37 AM, Daniel Knoppel <dan...@phusion.nl> wrote:
1. What is "passenger_set_cgi_params" was doing before? It seems phusion removed old docs and I couldn't find related info anywhere :(

The old docs are still available inside the old source tarballs, inside the 'doc' directory.

--
Phusion B.V. | Web Application deployment, scaling, and monitoring solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 63501007 (The Netherlands)
Reply all
Reply to author
Forward
0 new messages