Each /location can have its own run_as setting. You can do something like
server {
...
# Define the '/depts' location
location /depts {
run_as tim;
# Host a directory of applications
site_dir /srv/departmentApps;
# Provide a default/global GAID
google_analytics_id "UA-12345-1";
# Define the '/finance' location.
# Corresponds to the URL '/depts/finance', and the filesystem path
# '/srv/departmentApps/finance' as defined by the parent location.
location /finance {
run_as bob;
# Provide a custom GAID for only this sub-location
google_analytics_id "UA-54321-9";
}
}
...
See also the section 2.3.1 :HOME_USER: which explains how the application location can determine the user.