[how-to] simple access control: play but don't download

"Bruce M. Walker" <[email protected]> Fri, 18 Jul 2003 10:07:35 -0400 (EDT)
Newsgroups gmane.comp.apache.mod-mp3
Message-ID <[email protected]>
In case anybody is interested in mod_mp3 access control,
here's my solution to allowing streaming/playing of my MP3s
while discouraging downloading of them.  I make use of mod_rewrite
to note the web client ident string and allow known players.
I recognize many Linux/BSD (eg xmms, KDE) and Windows players,
(eg Winamp, RealPlayer). That list will need to updated as you
discover more players. (Check the Apache access logs.)

This technique is *not* foolproof and can be spoofed by a determined
person.  I employ it merely to discourage casual snarfing.  It also
stops the annoying download of several gigabytes that happens if
you choose Play in the mod_mp3 select web page without ticking any
songs.  (mod_mp3 streams the entire collection to the browser as a
single download.)

Anyway, here's my Apache conf.  The access control conf is
under "ACLs" ...

[Note that the 2nd RewriteCond line is one long line that begins:
  RewriteCond %{HTTP_USER_AGENT} !^(winampmpeg/
]


Listen 8000
<VirtualHost funk.borderware.com:8000>
        ServerName funk.borderware.com
        MP3Engine On
        MP3CastName "Bruce's Tunes"

        MP3DispatchAgent pgsql
        MP3PgConnectInfo "null" "nobody" "null"
        MP3PgInfo "music" "songs"
        MP3PgTokenTable "tokens"

        MP3Genre "various"
        MP3DefaultOperation select
        Timeout 3600
        ErrorLog /var/log/music_error_log

        # ACLs
        # only allow MP3 "players" to "play" our MP3s
        RewriteEngine on
        #RewriteLog "/var/log/rewrite.log"
        #RewriteLogLevel 4

        RewriteCond %{QUERY_STRING} op=play
        RewriteCond %{HTTP_USER_AGENT}
!^(winampmpeg/|nullsoft|xmms/|mpg123/|arts/|nsplayer/|rma/|oggvorbis) [nocase]
        RewriteRule /.* - [forbidden,last]
</VirtualHost>


-bmw