location ~ \.mp4$ {
        valid_referers blocked;
        if ($invalid_referer) {
            return 301;
		mp4_buffer_size       5m;
		mp4_max_buffer_size   30m;
Currently I use the above code against hotlink, and I'm having problems with mobile.

Especially those who use their own player "android iphone" because I believe that by using their players, they lose the reference, therefore, the hotlink and active.

I would then know how to release the hotlink for mobile only and leave the desktop.

I have the code below but I could not adapt to my need.
set $mobile_rewrite do_not_perform;

if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino") {
  set $mobile_rewrite perform;

if ($mobile_rewrite = perform) {
  rewrite ^ redirect;