I am following http://wiki.nginx.org/HttpBrowserModule tutorial.
I have the following configuration.
ancient_browser "MSIE 6.0";
if ($ancient_browser){
rewrite ^ /ie6;
}
the problem with this is that I get an infinity loop.
How do I make it work!? I'm surprised that even an example on an official doc. doesn't work.
Updated:
My current code
server {
listen 83;
server_name {my ip goes here}
location / {
ancient_browser "MSIE 6.0";
if ($ancient_browser){
rewrite ^ /ie6 break;
}
proxy_pass http://localhost:34881 ;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
proxy_set_header Country $geoip_country_code;
proxy_cache cache;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 404 1m;
add_header Pragma no-cache;
expires epoch;
if_modified_since off;
add_header Last-Modified "";
}
Update 2:
I came up with the following code snippet and it works.
if ($http_user_agent ~ "MSIE 6.0") {
set $IE T;
}
if ($uri != "/ie6/") {
set $IE "${IE}RUE";
}
if ($IE = TRUE) {
rewrite ^ /ie6 break;
}
if anyone has a better solution, please leave a comment..thanks!!!
Try to use
$http_user_agent
instead:or take a look at this topic.
Add
break
:The intent with the example was probably that the config not be applied in the location that you were rewriting to.
You need to make sure that you redirect the user to a part of the configuration that isn't handled by the same rule.
Does something like this work, perhaps?