Plex recently added the root hit redirect into its server, rendering this unnecessary:
if ($request_method != OPTIONS) {
set $test A;
}
if ($http_x_plex_device_name = '') {
set $test "${test}B";
}
if ($arg_X-Plex-Device-Name = '') {
set $test "${test}C";
}
if ($http_user_agent !~ (SmartTV)) {
set $test "${test}D";
}
#If the client isn't an app like a SmartTV and such, forward them to the web interface.
if ($test = ABCD) {
rewrite ^/$ $scheme://$http_host/web/index.html;
}
Plex recently added the root hit redirect into its server, rendering this unnecessary: