vhost.tpl.php 3.27 KB
Newer Older
1
<VirtualHost *:<?php print $http_port; ?>>
Adrian Rossouw's avatar
Adrian Rossouw committed
2
<?php if ($this->site_mail) : ?>
3
  ServerAdmin <?php  print $this->site_mail; ?>
4
<?php endif;?>
5

6 7 8 9 10 11 12 13 14
<?php
$aegir_root = drush_get_option('aegir_root');
if (!$aegir_root && $server->aegir_root) {
  $aegir_root = $server->aegir_root;
}
?>

  Alias /.well-known/acme-challenge <?php print $aegir_root; ?>/tools/le/.acme-challenges

15 16
  DocumentRoot <?php print $this->root; ?>

Adrian Rossouw's avatar
Adrian Rossouw committed
17
  ServerName <?php print $this->uri; ?>
18 19 20 21 22 23 24 25 26 27 28

  SetEnv db_type  <?php print urlencode($db_type); ?>

  SetEnv db_name  <?php print urlencode($db_name); ?>

  SetEnv db_user  <?php print urlencode($db_user); ?>

  SetEnv db_passwd  <?php print urlencode($db_passwd); ?>

  SetEnv db_host  <?php print urlencode($db_host); ?>

29 30
  SetEnv db_port  <?php print urlencode($db_port); ?>

31

32
<?php
33
if (sizeof($this->aliases)) {
34 35 36
  foreach ($this->aliases as $alias) {
    print "  ServerAlias " . $alias . "\n";
  }
37
}
38 39 40 41 42
?>

<IfModule mod_rewrite.c>
  RewriteEngine on
<?php
43
if ($this->redirection || $ssl_redirection) {
44

45
  if ($ssl_redirection && !$this->redirection) {
46
    print " # Redirect aliases in non-ssl to the same alias on ssl.\n";
47
    print " RewriteRule ^/*(.*)$ https://%{HTTP_HOST}/$1 [NE,L,R=301]\n";
48
  }
49
  elseif ($ssl_redirection && $this->redirection) {
50
    print " # Redirect all aliases + main uri to the main https uri.\n";
51
    print " RewriteRule ^/*(.*)$ https://{$this->uri}/$1 [NE,L,R=301]\n";
52
  }
53
  elseif (!$ssl_redirection && $this->redirection) {
54
    print " # Redirect all aliases to the main http url.\n";
55 56
    print " RewriteCond %{HTTP_HOST} !^{$this->redirection}$ [NC]\n";
    print " RewriteRule ^/*(.*)$ http://{$this->redirection}/$1 [NE,L,R=301]\n";
57 58 59
  }
}
?>
60 61 62 63
  RewriteRule ^/files/(.*)$ /sites/<?php print $this->uri; ?>/files/$1 [L]
  RewriteCond <?php print $this->site_path; ?>/files/robots.txt -f
  RewriteRule ^/robots.txt /sites/<?php print $this->uri; ?>/files/robots.txt [L]
</IfModule>
64 65 66 67

<?php print $extra_config; ?>

    # Error handler for Drupal > 4.6.7
68
    <Directory ~ "sites/.*/files">
69 70 71 72 73 74 75 76 77 78
      <Files *>
        SetHandler This_is_a_Drupal_security_line_do_not_remove
      </Files>
      Options None
      Options +FollowSymLinks

      # If we know how to do it safely, disable the PHP engine entirely.
      <IfModule mod_php5.c>
        php_flag engine off
      </IfModule>
79 80
    </Directory>

81 82 83
    # Prevent direct reading of files in the private dir.
    # This is for Drupal7 compatibility, which would normally drop
    # a .htaccess in those directories, but we explicitly ignore those
84
    <Directory "<?php print $this->site_path; ?>/private/" >
85 86 87 88 89 90 91 92 93 94 95
      <Files *>
        SetHandler This_is_a_Drupal_security_line_do_not_remove
      </Files>
      Deny from all
      Options None
      Options +FollowSymLinks

      # If we know how to do it safely, disable the PHP engine entirely.
      <IfModule mod_php5.c>
        php_flag engine off
      </IfModule>
96
    </Directory>
97

98 99 100 101 102
    # Allow access to hosting_le challenges directory.
    <Directory "<?php print $aegir_root; ?>/tools/le/.acme-challenges">
      Require all granted
    </Directory>

103 104
<?php
$if_subsite = $this->data['http_subdird_path'] . '/' . $this->uri;
105
if (provision_hosting_feature_enabled('subdirs') && provision_file()->exists($if_subsite)->status()) {
106 107 108
  print "  Include " . $if_subsite . "/*.conf\n";
}
?>
109

110
</VirtualHost>