subdir.tpl.php 41.6 KB
Newer Older
1
<?php
omega8cc's avatar
omega8cc committed
2 3 4 5 6 7 8 9 10 11
$script_user = drush_get_option('script_user');
if (!$script_user && $server->script_user) {
  $script_user = $server->script_user;
}

$aegir_root = drush_get_option('aegir_root');
if (!$aegir_root && $server->aegir_root) {
  $aegir_root = $server->aegir_root;
}

12 13 14 15
$nginx_config_mode = drush_get_option('nginx_config_mode');
if (!$nginx_config_mode && $server->nginx_config_mode) {
  $nginx_config_mode = $server->nginx_config_mode;
}
omega8cc's avatar
omega8cc committed
16

17 18 19 20
$phpfpm_mode = drush_get_option('phpfpm_mode');
if (!$phpfpm_mode && $server->phpfpm_mode) {
  $phpfpm_mode = $server->phpfpm_mode;
}
omega8cc's avatar
omega8cc committed
21

22 23 24 25
// We can use $server here once we have proper inheritance.
// See Provision_Service_http_nginx_ssl for details.
$phpfpm_socket_path = Provision_Service_http_nginx::getPhpFpmSocketPath();

26 27 28 29
$nginx_is_modern = drush_get_option('nginx_is_modern');
if (!$nginx_is_modern && $server->nginx_is_modern) {
  $nginx_is_modern = $server->nginx_is_modern;
}
omega8cc's avatar
omega8cc committed
30

memtkmcc's avatar
memtkmcc committed
31 32 33 34 35
$nginx_has_etag = drush_get_option('nginx_has_etag');
if (!$nginx_has_etag && $server->nginx_has_etag) {
  $nginx_has_etag = $server->nginx_has_etag;
}

omega8cc's avatar
omega8cc committed
36 37 38 39 40
$nginx_has_http2 = drush_get_option('nginx_has_http2');
if (!$nginx_has_http2 && $server->nginx_has_http2) {
  $nginx_has_http2 = $server->nginx_has_http2;
}

omega8cc's avatar
omega8cc committed
41 42 43 44 45
$nginx_has_gzip = drush_get_option('nginx_has_gzip');
if (!$nginx_has_gzip && $server->nginx_has_gzip) {
  $nginx_has_gzip = $server->nginx_has_gzip;
}

46 47 48 49
$nginx_has_upload_progress = drush_get_option('nginx_has_upload_progress');
if (!$nginx_has_upload_progress && $server->nginx_has_upload_progress) {
  $nginx_has_upload_progress = $server->nginx_has_upload_progress;
}
omega8cc's avatar
omega8cc committed
50

51 52 53 54
$satellite_mode = drush_get_option('satellite_mode');
if (!$satellite_mode && $server->satellite_mode) {
  $satellite_mode = $server->satellite_mode;
}
omega8cc's avatar
omega8cc committed
55

56 57
$subdir_loc = str_replace('/', '_', $subdir);
$subdir_dot = str_replace('/', '.', $subdir);
58
?>
59 60 61 62 63 64 65 66 67 68 69 70 71 72
<?php
  // If any of those parameters is empty for any reason, like after an attempt
  // to import complete platform with sites without importing their databases,
  // it will break Nginx reload and even shutdown all sites on the system on
  // Nginx restart, so we need to use dummy placeholders to avoid affecting
  // other sites on the system if this site is broken.
  if (!$db_type || !$db_name || !$db_user || !$db_passwd || !$db_host) {
    $db_type = 'mysqli';
    $db_name = 'none';
    $db_user = 'none';
    $db_passwd = 'none';
    $db_host = 'localhost';
  }
?>
73 74 75 76 77
<?php
  // Until the real source of this problem is fixed elsewhere, we have to
  // use this simple fallback to guarantee that empty db_port does not
  // break Nginx reload which results with downtime for the affected vhosts.
  if (!$db_port) {
78 79 80 81 82 83 84
    $ctrlf = '/data/conf/' . $script_user . '_use_proxysql.txt';
    if (provision_file()->exists($ctrlf)->status()) {
      $db_port = '6033';
    }
    else {
      $db_port = $this->server->db_port ? $this->server->db_port : '3306';
    }
85 86
  }
?>
87 88 89 90 91 92 93 94
#######################################################
<?php if ($nginx_config_mode == 'extended'): ?>
###  nginx.conf site level extended vhost include start
<?php else: ?>
###  nginx.conf site level basic vhost include start
<?php endif; ?>
#######################################################

95
set $subdir_main_site_name "<?php print $this->uri; ?>";
96

97 98 99 100 101
###
### Use the main site name if available, instead of
### potentially virtual server_name when alias is set
### as redirection target. See #2358977 for details.
###
102 103
if ($subdir_main_site_name = '') {
  set $subdir_main_site_name "$server_name";
104 105
}

106 107 108 109 110 111 112 113 114 115 116 117 118 119
# Mitigation for https://www.drupal.org/SA-CORE-2018-002
set $rce "ZZ";
if ( $query_string ~* (23value|23default_value|element_parents=%23) ) {
  set $rce "A";
}

if ( $request_method = POST ) {
  set $rce "${rce}B";
}

if ( $rce = "AB" ) {
  return 403;
}

120
<?php if ($nginx_config_mode == 'extended'): ?>
121 122 123 124
###
### Add recommended HTTP headers
###
add_header X-Content-Type-Options nosniff;
125
add_header X-XSS-Protection "1; mode=block";
126

127 128 129 130 131
###
### Helper locations to avoid 404 on legacy images paths
###
location ^~ /<?php print $subdir; ?>/sites/default/files {

132 133 134 135
  add_header Access-Control-Allow-Origin *;
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";

136 137 138 139 140 141 142
  root  <?php print "{$this->root}"; ?>;

  location ~* ^/<?php print $subdir; ?>/sites/default/files/imagecache {
    access_log off;
    log_not_found off;
    expires    30d;
    set $nocache_details "Skip";
143
    rewrite ^/<?php print $subdir; ?>/sites/default/files/imagecache/(.*)$ /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/imagecache/$1 last;
144
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
145 146 147 148 149 150
  }
  location ~* ^/<?php print $subdir; ?>/sites/default/files/styles {
    access_log off;
    log_not_found off;
    expires    30d;
    set $nocache_details "Skip";
151
    rewrite ^/<?php print $subdir; ?>/sites/default/files/styles/(.*)$ /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/styles/$1 last;
152
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
153 154 155 156 157
  }
  location ~* ^/<?php print $subdir; ?>/sites/default/files {
    access_log off;
    log_not_found off;
    expires    30d;
158
    rewrite ^/<?php print $subdir; ?>/sites/default/files/(.*)$ /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/$1 last;
159 160 161 162 163
    try_files /$1 $uri =404;
  }
}
<?php endif; ?>

164 165 166 167 168 169 170 171 172 173
###
### Master location for subdir support (start)
###
location ^~ /<?php print $subdir; ?> {

  root  <?php print "{$this->root}"; ?>;

<?php if ($nginx_config_mode == 'extended'): ?>
  set $nocache_details "Cache";

174 175 176 177 178 179 180 181
<?php if ($satellite_mode == 'boa'): ?>
  ###
  ### Deny crawlers.
  ###
  if ($is_crawler) {
    return 403;
  }

182 183 184 185 186 187 188
  ###
  ### Block semalt botnet.
  ###
  if ($is_botnet) {
    return 403;
  }

189 190 191 192
  ###
  ### Include high load protection config if exists.
  ###
  include /data/conf/nginx_high_load.c*;
omega8cc's avatar
omega8cc committed
193 194 195 196

  ###
  ### Include PHP-FPM version override logic if exists.
  ###
omega8cc's avatar
omega8cc committed
197
  include <?php print $aegir_root; ?>/config/server_master/nginx/post.d/fpm_include*;
omega8cc's avatar
omega8cc committed
198 199 200 201 202 203

  ###
  ### Allow to use non-default PHP-FPM version for the site
  ### listed in the special include file.
  ###
  if ($user_socket = '') {
omega8cc's avatar
omega8cc committed
204
    set $user_socket "<?php print $script_user; ?>";
omega8cc's avatar
omega8cc committed
205
  }
206 207
<?php endif; ?>

208 209 210 211 212 213 214
  ###
  ### Deny not compatible request methods without 405 response.
  ###
  if ( $request_method !~ ^(?:GET|HEAD|POST|PUT|DELETE|OPTIONS)$ ) {
    return 403;
  }

215
<?php if ($nginx_config_mode == 'extended'): ?>
216 217 218 219 220 221
  ###
  ### Deny listed requests for security reasons.
  ###
  if ($is_denied) {
    return 403;
  }
222
<?php endif; ?>
223

omega8cc's avatar
omega8cc committed
224 225 226 227 228 229 230
  ###
  ### HTTPRL standard support.
  ###
  location ^~ /<?php print $subdir; ?>/httprl_async_function_callback {
    location ~* ^/<?php print $subdir; ?>/httprl_async_function_callback {
      access_log off;
      set $nocache_details "Skip";
231
      try_files /httprl_async_function_callback $uri @drupal_<?php print $subdir_loc; ?>;
omega8cc's avatar
omega8cc committed
232
    }
233 234
  }

omega8cc's avatar
omega8cc committed
235 236 237 238 239 240 241
  ###
  ### HTTPRL test mode support.
  ###
  location ^~ /<?php print $subdir; ?>/admin/httprl-test {
    location ~* ^/<?php print $subdir; ?>/admin/httprl-test {
      access_log off;
      set $nocache_details "Skip";
242
      try_files /admin/httprl-test $uri @drupal_<?php print $subdir_loc; ?>;
omega8cc's avatar
omega8cc committed
243
    }
244 245
  }

omega8cc's avatar
omega8cc committed
246 247 248 249 250 251 252 253 254 255 256
  ###
  ### CDN Far Future expiration support.
  ###
  location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
    tcp_nodelay   off;
    access_log    off;
    log_not_found off;
    etag          off;
    gzip_http_version 1.0;
    if_modified_since exact;
    set $nocache_details "Skip";
257
    location ~* ^/<?php print $subdir; ?>/(cdn/farfuture/.+\.(?:css|js|jpe?g|gif|png|ico|bmp|svg|swf|pdf|docx?|xlsx?|pptx?|tiff?|txt|rtf|class|otf|ttf|woff2?|eot|less))$ {
omega8cc's avatar
omega8cc committed
258 259 260 261
      expires max;
      add_header X-Header "CDN Far Future Generator 1.0";
      add_header Cache-Control "no-transform, public";
      add_header Last-Modified "Wed, 20 Jan 1988 04:20:42 GMT";
262 263
      add_header Access-Control-Allow-Origin *;
      add_header X-Content-Type-Options nosniff;
264
      add_header X-XSS-Protection "1; mode=block";
omega8cc's avatar
omega8cc committed
265
      rewrite ^/<?php print $subdir; ?>/cdn/farfuture/[^/]+/[^/]+/(.+)$ /$1 break;
266
      try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
omega8cc's avatar
omega8cc committed
267 268 269 270 271
    }
    location ~* ^/<?php print $subdir; ?>/(cdn/farfuture/) {
      expires epoch;
      add_header X-Header "CDN Far Future Generator 1.1";
      add_header Cache-Control "private, must-revalidate, proxy-revalidate";
272 273
      add_header Access-Control-Allow-Origin *;
      add_header X-Content-Type-Options nosniff;
274
      add_header X-XSS-Protection "1; mode=block";
omega8cc's avatar
omega8cc committed
275
      rewrite ^/<?php print $subdir; ?>/cdn/farfuture/[^/]+/[^/]+/(.+)$ /$1 break;
276
      try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
omega8cc's avatar
omega8cc committed
277
    }
278
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
279
  }
280 281 282 283 284 285 286 287 288
<?php endif; ?>

  ###
  ### If favicon else return error 204.
  ###
  location = /<?php print $subdir; ?>/favicon.ico {
    access_log    off;
    log_not_found off;
    expires       30d;
289 290 291
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
292
    try_files     /sites/$subdir_main_site_name/files/favicon.ico /sites/$host/files/favicon.ico /favicon.ico $uri =204;
293 294 295 296 297 298 299 300 301
  }

  ###
  ### Support for http://drupal.org/project/robotstxt module
  ### and static file in the sites/domain/files directory.
  ###
  location = /<?php print $subdir; ?>/robots.txt {
    access_log    off;
    log_not_found off;
302 303 304
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
305
<?php if ($nginx_config_mode == 'extended'): ?>
306
    try_files /sites/$subdir_main_site_name/files/$host.robots.txt /sites/$subdir_main_site_name/files/robots.txt /sites/$host/files/robots.txt /robots.txt $uri @cache_<?php print $subdir_loc; ?>;
307
<?php else: ?>
308
    try_files /sites/$subdir_main_site_name/files/$host.robots.txt /sites/$subdir_main_site_name/files/robots.txt /sites/$host/files/robots.txt /robots.txt $uri @drupal_<?php print $subdir_loc; ?>;
309 310 311 312 313 314 315 316 317 318 319 320
<?php endif; ?>
  }

<?php if ($nginx_config_mode == 'extended'): ?>
  ###
  ### Allow local access to support wget method in Aegir settings
  ### for running sites cron.
  ###
  location = /<?php print $subdir; ?>/cron.php {

    include       fastcgi_params;

321 322 323
    # Block https://httpoxy.org/ attacks.
    fastcgi_param HTTP_PROXY "";

324 325 326 327 328
    fastcgi_param db_type   <?php print urlencode($db_type); ?>;
    fastcgi_param db_name   <?php print urlencode($db_name); ?>;
    fastcgi_param db_user   <?php print urlencode($db_user); ?>;
    fastcgi_param db_passwd <?php print urlencode($db_passwd); ?>;
    fastcgi_param db_host   <?php print urlencode($db_host); ?>;
329
    fastcgi_param db_port   <?php print urlencode($db_port); ?>;
330

331
    fastcgi_param  HTTP_HOST           <?php print $this->uri; ?>;
332 333
    fastcgi_param  RAW_HOST            $host;
    fastcgi_param  SITE_SUBDIR         <?php print $subdir; ?>;
334
    fastcgi_param  MAIN_SITE_NAME      <?php print $this->uri; ?>;
335 336 337 338 339 340 341 342 343

    fastcgi_param  REDIRECT_STATUS     200;
    fastcgi_index  index.php;

    set $real_fastcgi_script_name cron.php;
    fastcgi_param SCRIPT_FILENAME <?php print "{$this->root}"; ?>/$real_fastcgi_script_name;

    tcp_nopush   off;
    keepalive_requests 0;
344 345 346 347
<?php if ($satellite_mode == 'boa'): ?>
    allow        127.0.0.1;
    deny         all;
<?php endif; ?>
348
    try_files    /cron.php $uri =404;
omega8cc's avatar
omega8cc committed
349
<?php if ($satellite_mode == 'boa'): ?>
omega8cc's avatar
omega8cc committed
350
    fastcgi_pass unix:/var/run/$user_socket.fpm.socket;
omega8cc's avatar
omega8cc committed
351
<?php elseif ($phpfpm_mode == 'port'): ?>
352 353
    fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
354
    fastcgi_pass unix:<?php print $phpfpm_socket_path; ?>;
355 356 357
<?php endif; ?>
  }

358 359 360 361 362 363 364 365 366 367
  ###
  ### Allow local access to support wget method in Aegir settings
  ### for running sites cron in Drupal 8.
  ###
  location = /<?php print $subdir; ?>/cron/ {
<?php if ($satellite_mode == 'boa'): ?>
    access_log   off;
    allow        127.0.0.1;
    deny         all;
<?php endif; ?>
368
    try_files    $uri @drupal_<?php print $subdir_loc; ?>;
369 370
  }

371 372 373 374 375 376
  ###
  ### Send search to php-fpm early so searching for node.js will work.
  ### Deny bots on search uri.
  ###
  location ^~ /<?php print $subdir; ?>/search {
    location ~* ^/<?php print $subdir; ?>/search {
377
      if ( $is_bot ) {
378 379
        return 403;
      }
380
      try_files /search $uri @drupal_<?php print $subdir_loc; ?>;
381 382 383
    }
  }

384 385 386 387 388
  ###
  ### Support for https://drupal.org/project/js module.
  ###
  location ^~ /<?php print $subdir; ?>/js/ {
    location ~* ^/<?php print $subdir; ?>/js/ {
389
      if ( $is_bot ) {
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
        return 403;
      }
      rewrite ^/<?php print $subdir; ?>/(.*)$ /js.php?q=$1 last;
    }
  }

<?php if ($nginx_has_upload_progress): ?>
  ###
  ### Upload progress support.
  ### https://drupal.org/project/filefield_nginx_progress
  ### http://github.com/masterzen/nginx-upload-progress-module
  ###
  location ~ (?<upload_form_uri>.*)/x-progress-id:(?<upload_id>\d*) {
    access_log off;
    rewrite ^ $upload_form_uri?X-Progress-ID=$upload_id;
  }
  location ^~ /<?php print $subdir; ?>/progress {
    access_log off;
    upload_progress_json_output;
    report_uploads uploads;
  }
<?php endif; ?>

<?php if ($satellite_mode == 'boa'): ?>
  ###
  ### Deny cache details display.
  ###
  location ^~ /<?php print $subdir; ?>/admin/settings/performance/cache-backend {
    access_log off;
omega8cc's avatar
omega8cc committed
419
    return 301 $scheme://$host/<?php print $subdir; ?>/admin/settings/performance;
420 421 422 423 424 425 426
  }

  ###
  ### Deny cache details display.
  ###
  location ^~ /<?php print $subdir; ?>/admin/config/development/performance/redis {
    access_log off;
omega8cc's avatar
omega8cc committed
427
    return 301 $scheme://$host/<?php print $subdir; ?>/admin/config/development/performance;
428 429 430
  }
<?php endif; ?>

431 432 433 434
  ###
  ### Support for backup_migrate module download/restore/delete actions.
  ###
  location ^~ /<?php print $subdir; ?>/admin {
435
    if ( $is_bot ) {
436 437 438 439
      return 403;
    }
    access_log off;
    set $nocache_details "Skip";
440
    try_files /admin $uri @drupal_<?php print $subdir_loc; ?>;
441 442 443 444 445 446
  }

  ###
  ### Avoid caching /civicrm* and protect it from bots.
  ###
  location ^~ /<?php print $subdir; ?>/civicrm {
447
    if ( $is_bot ) {
448 449 450
      return 403;
    }
    set $nocache_details "Skip";
451
    try_files /civicrm $uri @drupal_<?php print $subdir_loc; ?>;
452 453 454 455 456 457 458
  }

  ###
  ### Support for audio module.
  ###
  location ^~ /<?php print $subdir; ?>/audio/download {
    location ~* ^/<?php print $subdir; ?>/(audio/download/.*/.*\.(?:mp3|mp4|m4a|ogg))$ {
459
      if ( $is_bot ) {
460 461 462
        return 403;
      }
      tcp_nopush off;
463 464
      access_log    off;
      log_not_found off;
465
      set $nocache_details "Skip";
466
      try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
467 468 469 470 471 472 473
    }
  }
<?php endif; ?>

  ###
  ### Deny listed requests for security reasons.
  ###
474
  location ~* (\.(?:git.*|htaccess|engine|config|inc|ini|info|install|make|module|profile|test|pl|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save))$ {
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
    access_log off;
    return 404;
  }

  ###
  ### Deny listed requests for security reasons.
  ###
  location ~* /(?:modules|themes|libraries)/.*\.(?:txt|md)$ {
    access_log off;
    return 404;
  }

  ###
  ### Deny listed requests for security reasons.
  ###
memtkmcc's avatar
memtkmcc committed
490 491 492 493 494 495 496 497 498
  location ~* /files/civicrm/(?:ConfigAndLog|custom|upload|templates_c) {
    access_log off;
    return 404;
  }

  ###
  ### Deny often flooded URI for performance reasons
  ###
  location = /<?php print $subdir; ?>/autodiscover/autodiscover.xml {
499 500
    access_log off;
    return 404;
501 502 503 504 505 506 507 508 509 510 511 512 513 514
  }

<?php if ($nginx_config_mode == 'extended'): ?>
  ###
  ### Responsive Images support.
  ### http://drupal.org/project/responsive_images
  ###
  location ~* ^/<?php print $subdir; ?>/.*\.r\.(?:jpe?g|png|gif) {
    if ( $http_cookie ~* "rwdimgsize=large" ) {
      rewrite ^/<?php print $subdir; ?>/(.*)/mobile/(.*)\.r(\.(?:jpe?g|png|gif))$ /<?php print $subdir; ?>/$1/desktop/$2$3 last;
    }
    rewrite ^/<?php print $subdir; ?>/(.*)\.r(\.(?:jpe?g|png|gif))$ /<?php print $subdir; ?>/$1$2 last;
    access_log off;
    set $nocache_details "Skip";
515
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
516 517 518 519 520 521 522 523 524 525 526 527
  }

  ###
  ### Adaptive Image Styles support.
  ### http://drupal.org/project/ais
  ###
  location ~* ^/<?php print $subdir; ?>/(?:.+)/files/styles/adaptive/(?:.+)$ {
    if ( $http_cookie ~* "ais=(?<ais_cookie>[a-z0-9-_]+)" ) {
      rewrite ^/<?php print $subdir; ?>/(.+)/files/styles/adaptive/(.+)$ /<?php print $subdir; ?>/$1/files/styles/$ais_cookie/$2 last;
    }
    access_log off;
    set $nocache_details "Skip";
528
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
529 530 531
  }
<?php endif; ?>

532 533 534 535 536
  ###
  ### Map /<?php print $subdir; ?>/files/ shortcut early to avoid overrides in other locations.
  ###
  location ^~ /<?php print $subdir; ?>/files/ {

537 538 539 540
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";

541 542 543 544 545 546 547 548 549 550
    ###
    ### Sub-location to support files/styles with short URIs.
    ###
    location ~* /<?php print $subdir; ?>/files/styles/(.*)$ {
      access_log off;
      log_not_found off;
      expires    30d;
<?php if ($nginx_config_mode == 'extended'): ?>
      set $nocache_details "Skip";
<?php endif; ?>
551
      rewrite  ^/<?php print $subdir; ?>/files/(.*)$  /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/$1 last;
552
      try_files  /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/styles/$1 $uri @drupal_<?php print $subdir_loc; ?>;
553 554 555 556 557 558 559 560 561 562 563
    }

    ###
    ### Sub-location to support files/imagecache with short URIs.
    ###
    location ~* /<?php print $subdir; ?>/files/imagecache/(.*)$ {
      access_log off;
      log_not_found off;
      expires    30d;
<?php if ($nginx_config_mode == 'extended'): ?>
      # fix common problems with old paths after import from standalone to Aegir multisite
564 565
      rewrite ^/<?php print $subdir; ?>/files/imagecache/(.*)/sites/default/files/(.*)$ /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/imagecache/$1/$2 last;
      rewrite ^/<?php print $subdir; ?>/files/imagecache/(.*)/files/(.*)$               /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/imagecache/$1/$2 last;
566 567
      set $nocache_details "Skip";
<?php endif; ?>
568
      rewrite  ^/<?php print $subdir; ?>/files/(.*)$  /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/$1 last;
569
      try_files  /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/imagecache/$1 $uri @drupal_<?php print $subdir_loc; ?>;
570 571
    }

572
    location ~* ^.+\.(?:pdf|jpe?g|gif|png|ico|bmp|svg|swf|docx?|xlsx?|pptx?|tiff?|txt|rtf|vcard|vcf|cgi|bat|pl|dll|class|otf|ttf|woff2?|eot|less|avi|mpe?g|mov|wmv|mp3|ogg|ogv|wav|midi|zip|tar|t?gz|rar|dmg|exe|apk|pxl|ipa|css|js)$ {
573 574 575 576
      expires       30d;
      tcp_nodelay   off;
      access_log    off;
      log_not_found off;
577
      rewrite  ^/<?php print $subdir; ?>/files/(.*)$  /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/$1 last;
578 579 580
      try_files   $uri =404;
    }
<?php if ($nginx_config_mode == 'extended'): ?>
581
    try_files /$1 $uri @cache_<?php print $subdir_loc; ?>;
582
<?php else: ?>
583
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
584 585 586 587
<?php endif; ?>
  }


588 589 590 591 592 593 594
  ###
  ### The s3/files/styles (s3fs) support.
  ###
  location ~* ^/<?php print $subdir; ?>/s3/files/styles/(.*)$ {
    access_log off;
    log_not_found off;
    expires    30d;
595 596 597
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
598 599 600
<?php if ($nginx_config_mode == 'extended'): ?>
    set $nocache_details "Skip";
<?php endif; ?>
601
    try_files  /<?php print $subdir; ?>/sites/$subdir_main_site_name/files/styles/$1 $uri @drupal_<?php print $subdir_loc; ?>;
602 603
  }

604 605 606 607 608 609 610
  ###
  ### Imagecache and imagecache_external support.
  ###
  location ~* ^/<?php print $subdir; ?>/((?:external|system|files/imagecache|files/styles)/.*) {
    access_log off;
    log_not_found off;
    expires    30d;
611 612 613
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
614 615 616
<?php if ($nginx_config_mode == 'extended'): ?>
    set $nocache_details "Skip";
<?php endif; ?>
617
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
618 619 620 621 622 623 624 625 626 627
  }

  ###
  ### Deny direct access to backups.
  ###
  location ~* ^/<?php print $subdir; ?>/sites/.*/files/backup_migrate/ {
    access_log off;
    deny all;
  }

628 629 630 631 632 633 634 635
  ###
  ### Deny direct access to config files in Drupal 8.
  ###
  location ~* ^/<?php print $subdir; ?>/sites/.*/files/config_.* {
    access_log off;
    deny all;
  }

636 637 638 639 640 641
<?php if ($nginx_config_mode == 'extended'): ?>
  ###
  ### Private downloads are always sent to the drupal backend.
  ### Note: this location doesn't work with X-Accel-Redirect.
  ###
  location ~* ^/<?php print $subdir; ?>/(sites/.*/files/private/.*) {
642
    if ( $is_bot ) {
643 644 645 646 647 648
      return 403;
    }
    access_log off;
    rewrite    ^/<?php print $subdir; ?>/sites/.*/files/private/(.*)$ $scheme://$host/<?php print $subdir; ?>/system/files/private/$1 permanent;
    add_header X-Header "Private Generator 1.0a";
    set $nocache_details "Skip";
649
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
650 651 652 653 654 655 656 657 658
  }
<?php endif; ?>

  ###
  ### Deny direct access to private downloads in sites/domain/private.
  ### Note: this location works with X-Accel-Redirect.
  ###
  location ~* ^/<?php print $subdir; ?>/sites/.*/private/ {
<?php if ($nginx_config_mode == 'extended'): ?>
659
    if ( $is_bot ) {
660 661 662 663 664 665 666 667 668 669 670 671 672
      return 403;
    }
<?php endif; ?>
    access_log off;
    internal;
  }

<?php if ($nginx_config_mode == 'extended'): ?>
  ###
  ### Deny direct access to private downloads also for short, rewritten URLs.
  ### Note: this location works with X-Accel-Redirect.
  ###
  location ~* /<?php print $subdir; ?>/files/private/ {
673
    if ( $is_bot ) {
674 675 676 677 678 679 680 681 682 683 684 685
      return 403;
    }
    access_log off;
    internal;
  }

  ###
  ### Wysiwyg Fields support.
  ###
  location ~* ^/<?php print $subdir; ?>/(.*/wysiwyg_fields/(?:plugins|scripts)/.*\.(?:js|css)) {
    access_log off;
    log_not_found off;
686 687 688 689
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
690 691 692 693 694 695 696
  }

  ###
  ### Advagg_css and Advagg_js support.
  ###
  location ~* ^/<?php print $subdir; ?>/(.*/files/advagg_(?:css|js).*) {
    expires    max;
697
    access_log off;
memtkmcc's avatar
memtkmcc committed
698
<?php if ($nginx_has_etag): ?>
699 700
    etag       off;
<?php else: ?>
701
    add_header ETag "";
702
<?php endif; ?>
703
    add_header X-Header "AdvAgg Generator 2.0";
704
    add_header Cache-Control "max-age=31449600, no-transform, public";
705
    add_header Access-Control-Allow-Origin *;
706
    add_header X-Content-Type-Options nosniff;
707
    add_header X-XSS-Protection "1; mode=block";
708
    set $nocache_details "Skip";
709
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
710 711 712 713 714 715 716 717 718
  }

  ###
  ### Make css files compatible with boost caching.
  ###
  location ~* ^/<?php print $subdir; ?>/(.*\.css)$ {
    access_log  off;
    tcp_nodelay off;
    expires     max; #if using aggregator
719 720 721
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
722 723 724 725 726 727 728 729 730 731
    try_files   /cache/perm/$host${uri}_.css /$1 $uri =404;
  }

  ###
  ### Make js files compatible with boost caching.
  ###
  location ~* ^/<?php print $subdir; ?>/(.*\.(?:js|htc))$ {
    access_log  off;
    tcp_nodelay off;
    expires     max; # if using aggregator
732 733 734
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
735 736 737 738
    try_files   /cache/perm/$host${uri}_.js /$1 $uri =404;
  }

  ###
739
  ### Support for static .json files with fast 404 +Boost compatibility.
740
  ###
741
  location ~* ^/<?php print $subdir; ?>/sites/.*/files/(.*\.json)$ {
742 743 744
    access_log  off;
    tcp_nodelay off;
    expires     max; ### if using aggregator
745 746 747
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
748 749
    try_files   /cache/normal/$host${uri}_.json /$1 $uri =404;
  }
750 751 752 753 754

  ###
  ### Support for dynamic .json requests.
  ###
  location ~* (.*\.json)$ {
755
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
756
  }
757 758 759 760 761 762
<?php endif; ?>

  ###
  ### Serve & no-log static files & images directly,
  ### without all standard drupal rewrites, php-fpm etc.
  ###
763
  location ~* ^/<?php print $subdir; ?>/(.+\.(?:jpe?g|gif|png|ico|bmp|svg|swf|pdf|docx?|xlsx?|pptx?|tiff?|txt|rtf|vcard|vcf|cgi|bat|pl|dll|aspx?|class|otf|ttf|woff2?|eot|less))$ {
764 765 766 767
    expires       30d;
    tcp_nodelay   off;
    access_log    off;
    log_not_found off;
768 769 770
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
771 772 773 774 775 776 777 778 779 780 781
    try_files   /$1 $uri =404;
  }

  ###
  ### Serve & log bigger media/static/archive files directly,
  ### without all standard drupal rewrites, php-fpm etc.
  ###
  location ~* ^/<?php print $subdir; ?>/(.+\.(?:avi|mpe?g|mov|wmv|mp3|mp4|m4a|ogg|ogv|flv|wav|midi|zip|tar|t?gz|rar|dmg|exe))$ {
    expires     30d;
    tcp_nodelay off;
    tcp_nopush  off;
782 783
    access_log    off;
    log_not_found off;
784 785 786
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
787 788 789 790 791 792 793 794 795 796
    try_files   /$1 $uri =404;
  }

  ###
  ### Serve & no-log some static files as is, without forcing default_type.
  ###
  location ~* ^/<?php print $subdir; ?>/((?:cross-?domain)\.xml)$ {
    access_log  off;
    tcp_nodelay off;
    expires     30d;
797 798 799
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
800 801 802 803 804 805 806 807 808
    try_files   /$1 $uri =404;
  }

<?php if ($nginx_config_mode == 'extended'): ?>
  ###
  ### Allow some known php files (like serve.php in the ad module).
  ###
  location ~* ^/<?php print $subdir; ?>/(.*/(?:modules|libraries)/(?:contrib/)?(?:ad|tinybrowser|f?ckeditor|tinymce|wysiwyg_spellcheck|ecc|civicrm|fbconnect|radioactivity)/.*\.php)$ {

809 810 811 812
<?php if ($satellite_mode == 'boa'): ?>
    limit_conn   limreq 88;
<?php endif; ?>

813 814
    include       fastcgi_params;

815 816 817
    # Block https://httpoxy.org/ attacks.
    fastcgi_param HTTP_PROXY "";

818 819 820 821 822
    fastcgi_param db_type   <?php print urlencode($db_type); ?>;
    fastcgi_param db_name   <?php print urlencode($db_name); ?>;
    fastcgi_param db_user   <?php print urlencode($db_user); ?>;
    fastcgi_param db_passwd <?php print urlencode($db_passwd); ?>;
    fastcgi_param db_host   <?php print urlencode($db_host); ?>;
823
    fastcgi_param db_port   <?php print urlencode($db_port); ?>;
824

825
    fastcgi_param  HTTP_HOST           <?php print $this->uri; ?>;
826 827
    fastcgi_param  RAW_HOST            $host;
    fastcgi_param  SITE_SUBDIR         <?php print $subdir; ?>;
828
    fastcgi_param  MAIN_SITE_NAME      <?php print $this->uri; ?>;
829 830 831 832 833 834 835 836 837 838

    fastcgi_param  REDIRECT_STATUS     200;
    fastcgi_index  index.php;

    set $real_fastcgi_script_name $1;
    fastcgi_param SCRIPT_FILENAME <?php print "{$this->root}"; ?>/$real_fastcgi_script_name;

    tcp_nopush   off;
    keepalive_requests 0;
    access_log   off;
839
    if ( $is_bot ) {
840 841 842
      return 403;
    }
    try_files    /$1 $uri =404;
omega8cc's avatar
omega8cc committed
843
<?php if ($satellite_mode == 'boa'): ?>
omega8cc's avatar
omega8cc committed
844
    fastcgi_pass unix:/var/run/$user_socket.fpm.socket;
omega8cc's avatar
omega8cc committed
845
<?php elseif ($phpfpm_mode == 'port'): ?>
846 847
    fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
848
    fastcgi_pass unix:<?php print $phpfpm_socket_path; ?>;
849 850 851
<?php endif; ?>
  }

852
  ###
853
  ### Deny crawlers and never cache known AJAX requests.
854
  ###
855
  location ~* ^/<?php print $subdir; ?>/(.*(?:ahah|ajax|batch|autocomplete|done|progress/|x-progress-id|js/.*).*)$ {
856
    if ( $is_bot ) {
857 858 859 860 861 862
      return 403;
    }
    access_log off;
    log_not_found off;
<?php if ($nginx_config_mode == 'extended'): ?>
    set $nocache_details "Skip";
863
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
864
<?php else: ?>
865
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
866 867 868
<?php endif; ?>
  }

869 870 871
  ###
  ### Serve & no-log static helper files used in some wysiwyg editors.
  ###
872
  location ~* ^/<?php print $subdir; ?>/(sites/.*/(?:modules|libraries)/(?:contrib/)?(?:tinybrowser|f?ckeditor|tinymce|flowplayer|jwplayer|videomanager)/.*\.(?:html?|xml))$ {
873
    if ( $is_bot ) {
874 875 876 877 878
      return 403;
    }
    access_log      off;
    tcp_nodelay     off;
    expires         30d;
879 880 881
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
882 883 884 885 886 887 888 889
    try_files /$1 $uri =404;
  }

  ###
  ### Serve & no-log any not specified above static files directly.
  ###
  location ~* ^/<?php print $subdir; ?>/(sites/.*/files/.*) {
    root  <?php print "{$this->root}"; ?>;
890
    rewrite     ^/<?php print $subdir; ?>/sites/(.*)$ /sites/$subdir_main_site_name/$1 last;
891 892 893
    access_log      off;
    tcp_nodelay     off;
    expires         30d;
894 895 896
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
897 898 899 900 901 902 903 904 905 906 907 908 909
    try_files /$1 $uri =404;
  }

  ###
  ### Make feeds compatible with boost caching and set correct mime type.
  ###
  location ~* ^/<?php print $subdir; ?>/(.*\.xml)$ {
    if ( $request_method = POST ) {
      return 405;
    }
    if ( $cache_uid ) {
      return 405;
    }
910
    error_page 405 = @drupal_<?php print $subdir_loc; ?>;
911
    access_log off;
912
    add_header X-Header "Boost Citrus 1.0";
913 914
    add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
    add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
915 916
    add_header Access-Control-Allow-Origin *;
    add_header X-Content-Type-Options nosniff;
917
    add_header X-XSS-Protection "1; mode=block";
918 919
    charset    utf-8;
    types { }
920
    default_type text/xml;
921
    try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html /$1 $uri @drupal_<?php print $subdir_loc; ?>;
922 923 924 925 926
  }

  ###
  ### Deny bots on never cached uri.
  ###
927
  location ~* ^/<?php print $subdir; ?>/((?:.*/)?(?:admin|user|cart|checkout|logout|comment/reply)) {
928
    if ( $is_bot ) {
929 930 931 932
      return 403;
    }
    access_log off;
    set $nocache_details "Skip";
933
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
934 935 936 937 938 939
  }

  ###
  ### Protect from DoS attempts on never cached uri.
  ###
  location ~* ^/<?php print $subdir; ?>/((?:.*/)?(?:node/[0-9]+/edit|node/add)) {
940
    if ( $is_bot ) {
941 942 943 944
      return 403;
    }
    access_log off;
    set $nocache_details "Skip";
945
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
946 947 948
  }

  ###
949
  ### Protect from DoS attempts on never cached uri.
950
  ###
951
  location ~* ^/<?php print $subdir; ?>/((?:.*/)?(?:node/[0-9]+/delete|approve)) {
952 953 954
    if ($cache_uid = '') {
      return 403;
    }
955
    if ( $is_bot ) {
956 957 958
      return 403;
    }
    access_log off;
959
    set $nocache_details "Skip";
960
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
961 962
  }
<?php endif; ?>
963

964
<?php if ($satellite_mode == 'boa'): ?>
965 966 967 968 969 970
  ###
  ### Workaround for https://www.drupal.org/node/2599326.
  ###
  if ( $args ~* "/autocomplete/" ) {
    return 405;
  }
971
  error_page 405 = @drupal_<?php print $subdir_loc; ?>;
972

973 974 975 976 977
  ###
  ### Rewrite legacy requests with /index.php to extension-free URL.
  ###
  if ( $args ~* "^q=(?<query_value>.*)" ) {
    rewrite ^/<?php print $subdir; ?>/index.php$ $scheme://$host/<?php print $subdir; ?>/?q=$query_value? permanent;
978 979 980
  }
<?php endif; ?>

981 982 983 984
  ###
  ### Redirect to working homepage.
  ###
  location = /<?php print $subdir; ?> {
omega8cc's avatar
omega8cc committed
985
    return 301 $scheme://$host/<?php print $subdir; ?>/;
986 987
  }

988 989 990 991 992
  ###
  ### Catch all unspecified requests.
  ###
  location /<?php print $subdir; ?>/ {
<?php if ($nginx_config_mode == 'extended'): ?>
993 994 995 996 997
<?php if ($satellite_mode == 'boa'): ?>
  if ( $http_user_agent ~* wget ) {
    return 403;
  }
<?php endif; ?>
998
    try_files /$1 $uri @cache_<?php print $subdir_loc; ?>;
999
<?php else: ?>
1000
    try_files /$1 $uri @drupal_<?php print $subdir_loc; ?>;
1001 1002 1003 1004 1005 1006
<?php endif; ?>
  }

  ###
  ### Send other known php requests/files to php-fpm without any caching.
  ###
1007 1008 1009
<?php if ($nginx_config_mode == 'extended'): ?>
  location ~* ^/<?php print $subdir; ?>/((core/)?(boost_stats|rtoc|js))\.php$ {
<?php else: ?>
1010
  location ~* ^/<?php print $subdir; ?>/(cron|boost_stats|update|authorize|xmlrpc)\.php$ {
1011 1012 1013
<?php endif; ?>
<?php if ($satellite_mode == 'boa'): ?>
    limit_conn   limreq 88;
1014
    if ( $is_bot ) {
1015 1016 1017
      return 404;
    }
<?php endif; ?>
1018 1019 1020

    include       fastcgi_params;

1021 1022 1023
    # Block https://httpoxy.org/ attacks.
    fastcgi_param HTTP_PROXY "";

1024 1025 1026 1027 1028
    fastcgi_param db_type   <?php print urlencode($db_type); ?>;
    fastcgi_param db_name   <?php print urlencode($db_name); ?>;
    fastcgi_param db_user   <?php print urlencode($db_user); ?>;
    fastcgi_param db_passwd <?php print urlencode($db_passwd); ?>;
    fastcgi_param db_host   <?php print urlencode($db_host); ?>;
1029
    fastcgi_param db_port   <?php print urlencode($db_port); ?>;
1030

1031
    fastcgi_param  HTTP_HOST           <?php print $this->uri; ?>;
1032 1033
    fastcgi_param  RAW_HOST            $host;
    fastcgi_param  SITE_SUBDIR         <?php print $subdir; ?>;
1034
    fastcgi_param  MAIN_SITE_NAME      <?php print $this->uri; ?>;
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045

    fastcgi_param  REDIRECT_STATUS     200;
    fastcgi_index  index.php;

    set $real_fastcgi_script_name $1.php;
    fastcgi_param SCRIPT_FILENAME <?php print "{$this->root}"; ?>/$real_fastcgi_script_name;

    tcp_nopush   off;
    keepalive_requests 0;
    access_log   off;
    try_files    /$1.php =404; ### check for existence of php file first
omega8cc's avatar
omega8cc committed
1046
<?php if ($satellite_mode == 'boa'): ?>
omega8cc's avatar
omega8cc committed
1047
    fastcgi_pass unix:/var/run/$user_socket.fpm.socket;
omega8cc's avatar
omega8cc committed
1048 1049
<?php elseif ($phpfpm_mode == 'port'): ?>
    fastcgi_pass 127.0.0.1:9000;
1050
<?php else: ?>
1051
    fastcgi_pass unix:<?php print $phpfpm_socket_path; ?>;
1052 1053 1054
<?php endif; ?>
  }

1055 1056 1057 1058 1059 1060
<?php if ($nginx_config_mode == 'extended'): ?>
  ###
  ### Allow access to /authorize.php and /update.php only for logged in admin user.
  ###
  location ~* ^/<?php print $subdir; ?>/((?:core/)?(authorize|update))\.php$ {
    set $real_fastcgi_script_name $1.php;
1061
    error_page 418 = @allowupdate_<?php print $subdir_loc; ?>;
1062 1063 1064 1065 1066 1067 1068
    if ( $cache_uid ) {
      return 418;
    }
    return 404;
  }
<?php endif; ?>

1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
  ###
  ### Rewrite legacy requests with /<?php print $subdir; ?>/index.php to extension-free URL.
  ###
  if ( $args ~* "^q=(?<query_value>.*)" ) {
    rewrite ^/<?php print $subdir; ?>/index.php$ $scheme://$host/<?php print $subdir; ?>/?q=$query_value? permanent;
  }

  ###
  ### Send all non-static requests to php-fpm, restricted to known php file.
  ###
  location = /<?php print $subdir; ?>/index.php {
1080
<?php if ($satellite_mode == 'boa'): ?>
1081 1082 1083 1084
    limit_conn limreq 888;
    add_header X-Device "$device";
    add_header X-GeoIP-Country-Code "$geoip_country_code";
    add_header X-GeoIP-Country-Name "$geoip_country_name";
1085 1086
<?php endif; ?>
<?php if ($nginx_config_mode == 'extended'): ?>
1087 1088 1089 1090 1091 1092 1093 1094
    add_header X-Speed-Cache "$upstream_cache_status";
    add_header X-Speed-Cache-UID "$cache_uid";
    add_header X-Speed-Cache-Key "$key_uri";
    add_header X-NoCache "$nocache_details";
    add_header X-This-Proto "$http_x_forwarded_proto";
    add_header X-Server-Sub-Name "$subdir_main_site_name";
    add_header X-Response-Status "$status";
    add_header X-Content-Type-Options nosniff;
1095
    add_header X-XSS-Protection "1; mode=block";
1096 1097
<?php endif; ?>

1098 1099 1100 1101
    root          <?php print "{$this->root}"; ?>;

    include       fastcgi_params;

1102 1103 1104
    # Block https://httpoxy.org/ attacks.
    fastcgi_param HTTP_PROXY "";

1105 1106 1107 1108 1109
    fastcgi_param db_type   <?php print urlencode($db_type); ?>;
    fastcgi_param db_name   <?php print urlencode($db_name); ?>;
    fastcgi_param db_user   <?php print urlencode($db_user); ?>;
    fastcgi_param db_passwd <?php print urlencode($db_passwd); ?>;
    fastcgi_param db_host   <?php print urlencode($db_host); ?>;
1110
    fastcgi_param db_port   <?php print urlencode($db_port); ?>;
1111

1112
    fastcgi_param  HTTP_HOST           $host;
1113 1114
    fastcgi_param  RAW_HOST            $host;
    fastcgi_param  SITE_SUBDIR         <?php print $subdir; ?>;
1115 1116
    fastcgi_param  SCRIPT_URL          /<?php print $subdir; ?>/;
    fastcgi_param  SCRIPT_URI          $scheme://$host/<?php print $subdir; ?>/;
1117
    fastcgi_param  MAIN_SITE_NAME      <?php print $this->uri; ?>;
1118 1119 1120 1121 1122 1123

    fastcgi_param  REDIRECT_STATUS     200;
    fastcgi_index  index.php;

    set $real_fastcgi_script_name index.php;
    fastcgi_param  SCRIPT_FILENAME     <?php print "{$this->root}"; ?>/$real_fastcgi_script_name;