Welcome! Log In Create A New Profile

Advanced

Rewite rule from Apache different in GET or POST

Posted by lunarok 
Rewite rule from Apache different in GET or POST
October 23, 2013 10:22AM
Hi,

I have some applications behind an Apache proxy actually. Will replace it by nginx. Actually for my tests, very happy.
But for few, I'm not able to reproduce the exact behaviour of Apache and still get errors.

For exemple, my XBMC reverse. I have under Apache a redirect for GET and a passthrough for POST requests.
I'm able to reproduce the rewritecond, but I'm failing to retrieve some file in the POST calls. So seems that's around the translation of the RewriteRule I have issue.

Can anyone help me ?

I have my Apache code with me (it's already in use) and will post my nginx tests as soon as possible.

#RewriteEngine On
# Redirect subrequests GET /foo/bar to GET /xbmc/foo/bar
RewriteCond %{HTTP_REFERER} ^https?://[^/]+/xbmc
RewriteCond %{REQUEST_URI} !^/xbmc
RewriteCond %{THE_REQUEST} ^GET
RewriteRule ^/(.*) /xbmc/$1 [QSA,R]
# Rewrite subrequests POST /foo/bar to POST /xbmc/foo/bar
RewriteCond %{HTTP_REFERER} ^https?://[^/]+/xbmc
RewriteCond %{REQUEST_URI} !^/xbmc
RewriteCond %{THE_REQUEST} ^POST
RewriteRule ^/(.*) /xbmc/$1 [QSA,PT]
ProxyPass /xbmc/ http://xbmc:8080/
ProxyPassReverse /xbmc/ http://xbmc:8080/

Thanks,

Cédric
Re: Rewite rule from Apache different in GET or POST
October 23, 2013 11:47AM
This is my nginx rules for now :

if ($http_referer ~ "^http?://[^/]+/xbmc"){
set $rule_0 1$rule_0;
}
if ($uri !~ "^/xbmc"){
set $rule_0 2$rule_0;
}
if ($request_method = POST) {
set $rule_0 3$rule_0;
}
if ($request_method = GET) {
set $rule_0 4$rule_0;
}
if ($rule_0 = "421"){
rewrite ^/(.*) /xbmc/$1;
}
if ($rule_0 = "321"){
rewrite ^/(.*) /xbmc/$1 redirect;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 102
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready