You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Julian Sareyka <ju...@sareyka.eu> on 2014/06/03 19:11:50 UTC
[users] Use dbd RewriteMap to map user friendly URLs to files in an object store
Hello,
this is our business case:
- we have an object store where we keep video and audio files, each file
identified by a technical key
- we can access this object store with the S3 protocol via http (example:
http://internal-object-store.de/bucket/key)
- we want to put a reverse proxy in front of the S3 gateway to deliver the
files and map user friendly urls to the technical keys (example:
http://videoserver.de/myNewVideo.mp4 ->
http://internal-object-store.de/bucket/key)
- the mappings must be in a database because there are new mappings every
hour for new files, and we delete the mappings for files that are no longer
publicly available
>From the documentation of mod_rewrite I found that we could achieve this
with a dbd RewriteMap (starting with httpd 2.4). I found very few
discussions about the dbd RewriteMap via Google but at last I got a basic
working example.
<VirtualHost *:80>
ServerName myserver.de
DBDriver mysql
DBDParams "host=my-db-host.de,port=3306,user=user,pass=pw,dbname=name"
DBDPersist On
DBDPrepareSQL "select S3_PATH from MAPPINGS where URL = %s" mappath
RewriteEngine On
RewriteMap avfile "dbd:select S3_PATH from MAPPINGS where URL = %s"
RewriteRule ^/s3(.*) http://internal-object-store.de${avfile:$1} [P]
</VirtualHost>
I was not able to use the label "mappath" of the prepared statement as a
reference in the RewriteMap directive.
for example:
RewriteMap avfile dbd:mappath
did not work.
Here are my questions:
Can the prepared statement be used in the RewriteMap? (And how?)
Has anybody experience with the dbd RewriteMap in production?
Are there any known pitfalls?
Would it be advisable to use a different approach. For example with mod_lua?
Thank you and best regards,
Julian
[users] Use dbd RewriteMap to map user friendly URLs to files in an object store
Posted by Julian Sareyka <j....@gmail.com>.
> Hello,
>
> this is our business case:
> - we have an object store where we keep video and audio files, each file
> identified by a technical key
> - we can access this object store with the S3 protocol via http (example:
> http://internal-object-store.de/bucket/key)
> - we want to put a reverse proxy in front of the S3 gateway to deliver the
> files and map user friendly urls to the technical keys (example:
> http://videoserver.de/myNewVideo.mp4 ->
> http://internal-object-store.de/bucket/key)
> - the mappings must be in a database because there are new mappings every
> hour for new files, and we delete the mappings for files that are no longer
> publicly available
>
> From the documentation of mod_rewrite I found that we could achieve this
> with a dbd RewriteMap (starting with httpd 2.4). I found very few
> discussions about the dbd RewriteMap via Google but at last I got a basic
> working example.
>
> <VirtualHost *:80>
> ServerName myserver.de
>
> DBDriver mysql
> DBDParams "host=my-db-host.de,port=3306,user=user,pass=pw,dbname=name"
> DBDPersist On
> DBDPrepareSQL "select S3_PATH from MAPPINGS where URL = %s" mappath
>
> RewriteEngine On
> RewriteMap avfile "dbd:select S3_PATH from MAPPINGS where URL = %s"
> RewriteRule ^/s3(.*) http://internal-object-store.de${avfile:$1} [P]
>
> </VirtualHost>
>
> I was not able to use the label "mappath" of the prepared statement as a
> reference in the RewriteMap directive.
> for example:
> RewriteMap avfile dbd:mappath
> did not work.
>
> Here are my questions:
> Can the prepared statement be used in the RewriteMap? (And how?)
> Has anybody experience with the dbd RewriteMap in production?
> Are there any known pitfalls?
> Would it be advisable to use a different approach. For example with
> mod_lua?
>
> Thank you and best regards,
> Julian
>
--
Viele Grüße,
Julian Sareyka