How can I bootstrap a multi-site instance? It's possible to bootstrap Drupal 8 and create a new node using answer # 174474.
define('DRUPAL_DIR', '/usr/share/nginx/html');

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

require_once DRUPAL_DIR . '/core/includes/database.inc';
require_once DRUPAL_DIR . '/core/includes/schema.inc';

// Specify relative path to the drupal root.
$autoloader = require_once DRUPAL_DIR . '/autoload.php';
$request = Request::createFromGlobals();

// Bootstrap drupal to different levels
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel-&gt;boot();
$kernel-&gt;prepareLegacyRequest($request);
$em = $kernel-&gt;getContainer()-&gt;get('entity.manager');

$entity = $em-&gt;getStorage('node')-&gt;create([
  'type' =&gt; &quot;article&quot;,
  'title' =&gt; &quot;test entity&quot;,
  'body' =&gt; &quot;body body body&quot;,
]);
$entity-&gt;save();

Is it possible to bootstrap a subsite database when using multisite to create the new node in a specific subsite?
In Drupal 7, this can be done by using the function drupal_override_server_variables, but this function doesn't exist in Drupal 8.
I also tried modifying the $_SERVER['HTTP_HOST'] and $_SERVER['SCRIPT_NAME'] variables according to this forum post, with no luck.
I was able to get this working by setting the server variable  $_SERVER['SCRIPT_NAME'] to '/subsite/index.php' (where /subsite/ is the url path to the subsite). 

$_SERVER['SCRIPT_NAME'] = '/subsite/index.php';

define('DRUPAL_DIR', '/usr/share/nginx/html');
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

require_once DRUPAL_DIR . '/core/includes/database.inc';
require_once DRUPAL_DIR . '/core/includes/schema.inc';

// Specify relative path to the drupal root.
$autoloader = require_once DRUPAL_DIR . '/autoload.php';
$request = Request::createFromGlobals();

// Bootstrap drupal to different levels
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel-&gt;boot();
$kernel-&gt;prepareLegacyRequest($request);
$em = $kernel-&gt;getContainer()-&gt;get('entity.manager');

$entity = $em-&gt;getStorage('node')-&gt;create(
array(
  'type' =&gt; "article",
  'title'=&gt; "test entity",
  'body' =&gt; "body body body",
));

$entity-&gt;save();