Change HTTP method of Sub request

I have a Rails app that receives a POST and I would like to
X-Accel-Redirect a file back to the client, but the fileserver is
receiving a POST. Can I rewrite the HTTP method internally? I cannot
find the documentation on this.

On Fri, Mar 19, 2010 at 9:24 AM, W. Andrew Loe III
[email protected] wrote:

I have a Rails app that receives a POST and I would like to
X-Accel-Redirect a file back to the client, but the fileserver is
receiving a POST. Can I rewrite the HTTP method internally? I cannot
find the documentation on this.

How about this?

location /proxy {
      set_unescape_uri $body $arg_body;
      echo_subrequest_async POST /fileserver -b $body
 }

Then X-Accel-Redirect to /proxy?body=xxxx where xxxx is the content
body that you have read from within your PHP script.

Good luck :slight_smile:
-agentzh

On Fri, Mar 19, 2010 at 3:02 PM, agentzh [email protected] wrote:

location /proxy {
set_unescape_uri $body $arg_body;
echo_subrequest_async POST /fileserver -b $body
}

Forgot to mention that set_unescape_uri is provided by the
ngx_set_misc module below:

http://github.com/agentzh/set-misc-nginx-module

and echo_subrequest_async is provided by the ngx_echo module:

http://github.com/agentzh/echo-nginx-module

Cheers,
-agentzh

Hello!

On Thu, Mar 18, 2010 at 06:24:30PM -0700, W. Andrew Loe III wrote:

I have a Rails app that receives a POST and I would like to
X-Accel-Redirect a file back to the client, but the fileserver is
receiving a POST. Can I rewrite the HTTP method internally? I cannot
find the documentation on this.

location /storage/ {
    proxy_pass http://storage-backend...;
    proxy_pass_method GET;
    proxy_pass_request_body off;
    proxy_set_header Content-Length "";
}

Maxim D.

proxy_pass_method does not exist in the 0.7 or 0.8 branches. There is
proxy_method but I believe it simply allows more than the standard 4
verbs to be proxied
(Module ngx_http_proxy_module).

Hello!

On Fri, Mar 19, 2010 at 10:02:31AM -0700, W. Andrew Loe III wrote:

proxy_pass_method does not exist in the 0.7 or 0.8 branches. There is

Yes, I was too lazy to recheck exact name.

proxy_method but I believe it simply allows more than the standard 4
verbs to be proxied
(Module ngx_http_proxy_module).

No, it sets method to be used in request to backend server.

Maxim D.

p.s. Please do not top-post. Thank you.

Hello!

On Fri, Mar 19, 2010 at 10:40:56AM -0700, W. Andrew Loe III wrote:

Thank you, it works as you suggest, the documentation could use some
clarification!

Feel free to fix it, it’s wiki.

Maxim D.

Thank you, it works as you suggest, the documentation could use some
clarification!