yaoweibin / nginx_ajp_module

support AJP protocol proxy with Nginx
http://github.com/yaoweibin/nginx_ajp_module
246 stars 59 forks source link

Sending arbitrary AJP request attributes (eg environment variables) #13

Open davidjb opened 11 years ago

davidjb commented 11 years ago

Is it currently possible to send arbitrary request attributes via this module? In particular, I'm curious as to whether it is possible to set environment variables in this fashion. For example, for mod_proxy_ajp for Apache, environment variables prefixed with AJP_ see this prefix stripped and are sent through as AJP request attributes (see https://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html#env). I'm curious as to how this can be done with Nginx as an auth module for Apache that I'm atttempting to replicate in Nginx relies on working in this fashion.

From http://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html:

Beyond this list of basic attributes, any number of other attributes can be sent via the req_attribute code (0x0A). A pair of strings to represent the attribute name and value are sent immediately after each instance of that code. Environment values are passed in via this method.

Thoughts?

davidjb commented 11 years ago

I see that the remote port info is being sent via a request attribute: https://github.com/yaoweibin/nginx_ajp_module/blob/master/ngx_http_ajp.c#L558

So to add this feature, it would just be a case of adding another configuration option (eg ajp_set_req_attribute); allowing it to be configured like something such as proxy_set_header (http://wiki.nginx.org/NginxHttpProxyModule#proxy_set_header); and then sending these in the AJP message.

Is this something that could be added?

Thanks!