More subdomain mapping (dynamic 'root'?)

miradev nginx-forum at nginx.us
Thu Jul 2 19:29:07 MSD 2009


No replies as yet.

This is what I have come up with so, but I'm not sure I am passing on the correct values to fcgi.
And I would like the log file locations to be a little dynamic.


server {
  listen       localhost:80;  # your server's public IP address
  server_name  .admin.domain.com;

  access_log /var/log/nginx/wordpress/admin/generic-access.log;
  error_log /var/log/nginx/wordpress/admin/generic-error.log;

  set $client $host;
  if ($client ~ "^(*).admin.domain.com"){
    set $client $1;
  }

  location ~ ^/([^/]*)/?(.*) {
    set $domain $1;
    set $myuri $2;
    root /var/www/wordpress/$client/admin/$domain/html;
    index  index.php index.html index.htm;
    if (-f $request_filename) {
      expires 30d;
      break;
    }

    try_files $domain/$myuri $domain/$myuri/ /$domain/index.php?q=$myuri&$args;
  }
}

  location ~ \.php$ {
    fastcgi_pass   localhost:57093;  # port where FastCGI processes were spawned
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME    /var/www/wordpress/$client/admin/$domain/html$fastcgi_script_name;  # same path as above

    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;

    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param  REQUEST_URI        $request_uri;
    fastcgi_param  DOCUMENT_URI       $document_uri;
    fastcgi_param  DOCUMENT_ROOT      $document_root;
    fastcgi_param  SERVER_PROTOCOL    $server_protocol;

    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

    fastcgi_param  REMOTE_ADDR        $remote_addr;
    fastcgi_param  REMOTE_PORT        $remote_port;
    fastcgi_param  SERVER_ADDR        $server_addr;
    fastcgi_param  SERVER_PORT        $server_port;
    fastcgi_param  SERVER_NAME        $server_name;

    # required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;
  }
}


Any helpful comments or musings much appreciated.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,3586,3673#msg-3673






More information about the nginx mailing list