Commit d3397519 by shammash Committed by lucha

Add blog->site map

We want per-blog traffic stats.

Apache noblogs is configured with a single virtualhost, we cannot use the
virtualhost name (%v) for these stats, because everything will appear as
noblogs.org .

We cannot even use the Host header (%{Host}i) because the virtualhost wildcard
configuration allows for bogus blog names (e.g. cavalle55e.noblogs.org instead
of cavallette.noblogs.org).

With this map nginx can lookup a valid blog name (or default to noblogs.org for
invalid names) and pass it to apache with an internal header (e.g.
X-AI-Noblogs-Site ). Apache will then use this header to produce correct stats.

Signed-off-by: shammash <shammash@autistici.org>
1 parent b2671a87
Showing with 21 additions and 4 deletions
......@@ -33,13 +33,11 @@ function backend_to_http_endpoint($backend) {
}
// Print the blog -> backend map.
function generate_map() {
function generate_backend_map($blogs) {
global $wpdb;
global $noblogs_master;
$wpdb_hash = &$wpdb->hash_map;
$blogs = get_blogs();
printline('map $http_host $backend_noblogs {');
printline(' default http://' . $noblogs_master . ':82;');
foreach ($blogs as $blog) {
......@@ -53,5 +51,24 @@ function generate_map() {
printline('}');
}
// Print the blog -> site map.
// This is used to send apache the right site name for logging purposes.
function generate_site_map($blogs) {
printline('map $http_host $site_noblogs {');
printline(' default noblogs.org;');
foreach ($blogs as $blog) {
$blog_id = $blog->blog_id;
if ($blog_id == 1)
continue;
printline(' ' . $blog->domain . ' ' . $blog->domain . ';');
  • Non capisco: questo crea una mappa del tipo

    cavallette.noblogs.org cavallette.noblogs.org

    che senso ha? è una mappa identità? (nota, questa modifica ha rotto un paio di tool di testing di noblogs...)

}
printline('}');
}
function generate_maps() {
$all_blogs = get_blogs();
generate_backend_map($all_blogs);
generate_site_map($all_blogs);
}
generate_map();
generate_maps();
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!