Welcome! Log In Create A New Profile

Advanced

redirect and proxy on the same location based on user agent

Posted by fadh 
redirect and proxy on the same location based on user agent
May 17, 2012 02:26AM
'm new to nginx, comming from apache and i basically want to do the following:

Based on user-agent: iPhone: redirect to iphone.mydomain.com
android: redirect to android.mydomain.com
facebook: reverse proxy to otherdomain.com
all other: redirect to ...
and tried it the following way:

location /tvoice {
if ($http_user_agent ~ iPhone ) {
rewrite ^(.*) https://m.domain1.com$1 permanent;
}
...
if ($http_user_agent ~ facebookexternalhit) {
proxy_pass http://mydomain.com/api;
}

rewrite /tvoice/(.*) http://mydomain.com/#!tvoice/$1 permanent;
}

But now i get an error when starting nginx:

nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except"

And i dont get how to do it or what the problem is.

Thanks



Edited 1 time(s). Last edit at 05/17/2012 02:27AM by fadh.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 85
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready