Hi all,
I'm actually migrating from lighttpd to nginx, and I'm trying to preserve some old conditionals.
In lighttpd, I have something like this:
[code]
$HTTP["referer"] =~ "^http://(labs\.|etc\.)example.com/" {
$HTTP["url"] =~ "\.(eot|otf|svg|woff|ttf|ogg|oga|ogv|m4a|m4v|mp3|mov|mp4|mov)$" {
setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*" )
}
}
[/code]
I attempted this in nginx:
[code]
location ~ "\.(eot|otf|svg|woff|ttf|ogg|oga|ogv|m4a|m4v|mp3|mov|mp4|mov)$" {
if ($http_referer ~ "^http://(labs\.|etc\.)example.com/") {
add_header Access-Control-Allow-Origin *;
}
}
[/code]
But this did absolutely nothing. No header appeared. Apparently, "add_header" does nothing (and is in error) inside an "if" directive.
I want to add this header so I can serve web fonts and multimedia to several sites while being consistent with the license these files are offered under. I know it's trivial to get around these rules, but I think it's my responsibility to take even small steps to comply with these very reasonable licenses.
Does anyone have any idea how I can do this in nginx?