I'm very new to nginx and hit the wall configuring simple redirection. Here is my very simple config trying redirection:
server { listen 80 default_server; set $mobile "false"; if ($http_user_agent ~* '(phone|droid)') { set $mobile "true"; } if ($mobile = true) { return 301 http://X.X.X.X/mobile$request_uri; } location /mobile { include uwsgi_params; uwsgi_pass unix:/var/www/video_m/video.sock; } location / { include uwsgi_params; uwsgi_pass unix:/var/www/video/video.sock; } } When go to site from desktop everything is ok and my request is going to uwsgi. But from mobile device I get an error from browser ERR_TOO_MANY_REDIRECTS and request url looks like http://X.X.X.X/mobile/mobile/mobile/mobile/mobile/mobile/mobile/mobile
There is obviously something essential and possibly very simple piece that I missing. Please help me out.