1

I need to block a hash which is inside a URL through nginx. The URL which requires to be blocked is

http://mp3string.com/video/Kill-My-DeMonZ---Mz-Sunday-Luv-%2B-Jeny-Cox-(-JopRec-)-@www.joprec.org%EF%BB%BF/mbqQMZXYL08`

Now if you see the URL the unique hash "mbqQMZXYL08" needs to be blocked through nginx.

I have already tried blocking the URL by adding to the server block, however it is not working.

    RewriteRule ^video/Kill-My-DeMonZ---Mz-Sunday-Luv-%2B-Jeny-Cox-(-JopRec-)-@www.joprec.org%EF%BB%BF/mbqQMZXYL08 - [F]

On my website every time any user opens a song it has a Unique hash, since it is a mp3 site and non of the songs are on the website I at times get DMCA to remove the URL.

The redirects I am using in my server block :

    rewrite ^/mp3/([0-9]+)/([^/]*)/([^/]*)(/?)+$ /?do=song&source=$1&title=$2&id=$3 last;
    rewrite ^/video/([^/]*)/([^/]*)(/?)+$ /?do=video&id=$2&title=$1 last;
    rewrite ^/search.html(/?)+$ /?do=search&$args last;
    rewrite ^/embed/([0-9]+)/([^/]*)/([^/]*)(/?)+$ /embed.php?source=$1&title=$2&id=$3&$args last;
    rewrite ^/logout(/?)+$ /?do=logout last;
    rewrite ^/settings(/?)+$ /?do=user last;
    rewrite ^/settings(/?)+$ /?do=user last;
    rewrite ^/playlist/edit/([0-9]+)(/?)+$ /?do=edit_playlist&id=$1 last;
    rewrite ^/playlist/([0-9]+)(/?)+$ /?do=playlist&id=$1 last;
    rewrite ^/playlists(/?)+$ /?do=playlists last;
    rewrite ^/playlists/([0-9]+)(/?)+$ /?do=playlists&p=$1 last;
    rewrite ^/([a-zA-Z0-9_-]+)(/?)$ /?do=profile&username=$1 last;
    rewrite ^/([a-zA-Z0-9_-]+)/favorites(/?)$ /?do=profile&username=$1&action=favorites last;
    rewrite ^/([a-zA-Z0-9_-]+)/playlists(/?)$ /?do=profile&username=$1&action=playlists last;
HBruijn
  • 72,524
  • 21
  • 127
  • 192
MrT
  • 13
  • 3

1 Answers1

1

Your URI seems to be broken or it contains weird symbols. I am not sure whether it's even HTTP-valid. I'd try to avoid such sick URI formatting.

However, if it is valid, then

location ~* .*mbqQMZXYL08 { return 403; break; }

should do the trick.

drookie
  • 8,051
  • 1
  • 17
  • 27