Add all files needed to bring up VM and run agaric.com locally
This commit is contained in:
parent
52c8b60bac
commit
4d2bc0ee24
742 changed files with 24037 additions and 0 deletions
392
box/provisioning/templates/dashboard.html.j2
Normal file
392
box/provisioning/templates/dashboard.html.j2
Normal file
|
@ -0,0 +1,392 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Drupal VM</title>
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="//cdn.rawgit.com/geerlingguy/drupalvm.github.io/master/favicon.ico" type="image/vnd.microsoft.icon" />
|
||||
<style>
|
||||
.section-host {
|
||||
font-family: monospace;
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
/* minor fallback styling for when loaded without an internet connection */
|
||||
.panel, .jumbotron, .well {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
td, th {
|
||||
padding: 8px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{# Sets vagrant IP if equals 0.0.0.0 #}
|
||||
{%- if vagrant_ip == '0.0.0.0' -%}
|
||||
{%- set vagrant_ip = ansible_all_ipv4_addresses[1] -%}
|
||||
{%- endif -%}
|
||||
{# Returns the hosts server name based on the document root #}
|
||||
{%- macro getServernameFromDocroot(path) -%}
|
||||
{%- if drupalvm_webserver == 'apache' -%}
|
||||
{%- for host in apache_vhosts -%}
|
||||
{%- if host.documentroot == path -%}
|
||||
{{ host.servername }}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- elif drupalvm_webserver == 'nginx' -%}
|
||||
{%- for host in nginx_vhosts -%}
|
||||
{%- if host.root == path -%}
|
||||
{{ host.server_name }}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro printSite(servername, docroot) -%}
|
||||
{%- if docroot not in _devtool_docroots -%}
|
||||
<tr>
|
||||
<td><a href="http://{{ servername }}">{{ servername }}</a></td>
|
||||
<td><code>{{ docroot }}</code></td>
|
||||
{% if configure_drush_aliases %}
|
||||
<td><code>drush @{{ vagrant_machine_name }}.{{ servername }}</code></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro printHostsEntry(ip, servername) -%}
|
||||
{%- if servername != ip -%}
|
||||
<li>{{ ip }} {{ servername }}</li>
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro sectionHost() -%}
|
||||
<ul class="section-host">
|
||||
{% if drupalvm_webserver == 'apache' -%}
|
||||
{%- for host in apache_vhosts -%}
|
||||
|
||||
{{ printHostsEntry(vagrant_ip, host.servername) }}
|
||||
{% if host.serveralias is defined -%}
|
||||
{%- for alias in host.serveralias.split() -%}
|
||||
{{ printHostsEntry(vagrant_ip, alias) }}
|
||||
{%- endfor -%}
|
||||
{%- endif %}
|
||||
|
||||
{%- endfor -%}
|
||||
{%- elif drupalvm_webserver == 'nginx' -%}
|
||||
{%- for host in nginx_vhosts -%}
|
||||
|
||||
{% for server_name in host.server_name.split(' ') -%}
|
||||
{{ printHostsEntry(vagrant_ip, server_name) }}
|
||||
{%- endfor %}
|
||||
{% if host.server_name_redirect is defined -%}
|
||||
{%- for server_name in host.server_name_redirect.split(' ') -%}
|
||||
{{ printHostsEntry(vagrant_ip, server_name) }}
|
||||
{%- endfor -%}
|
||||
{%- endif %}
|
||||
|
||||
{%- endfor -%}
|
||||
{%- endif %}
|
||||
</ul>
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro sectionSiteList() -%}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Hostname</th>
|
||||
<th>Document Root</th>
|
||||
{% if configure_drush_aliases -%}
|
||||
<th>Drush alias*</th>
|
||||
{%- endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if drupalvm_webserver == 'apache' -%}
|
||||
{%- for host in apache_vhosts -%}
|
||||
{%- if host.documentroot is defined -%}
|
||||
{{ printSite(host.servername, host.documentroot) }}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- elif drupalvm_webserver == 'nginx' -%}
|
||||
{%- for host in nginx_vhosts -%}
|
||||
{%- if host.root is defined -%}
|
||||
{%- for hostname in host.server_name.split() -%}
|
||||
{{ printSite(hostname, host.root) }}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endif %}
|
||||
<tr><td colspan=3><small>*Note: If Ansible isn't installed on your host, Drush aliases are only created inside the VM.</small></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro sectionDevelopmentTools() -%}
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
{% if not installed_extras -%}
|
||||
<tr>
|
||||
<td>There are no development tools installed inside the VM.</td>
|
||||
</tr>
|
||||
{%- endif -%}
|
||||
{% if 'adminer' in installed_extras -%}
|
||||
{% macro servername() %}{{ getServernameFromDocroot(adminer_install_dir) }}/{{ adminer_install_filename }}{% endmacro %}
|
||||
{%- if servername() != "/{{ adminer_install_filename }}" -%}
|
||||
<tr>
|
||||
<th>Adminer</th>
|
||||
<td><a href="http://{{ servername() }}">{{ servername() }}</a>
|
||||
</br>
|
||||
<a href="http://{{ servername() }}" class="btn btn-success btn-xs" role="button">Open</a>
|
||||
<a href="http://docs.drupalvm.com/en/latest/extras/mysql/#connect-using-adminer" target="_blank" class="btn btn-info btn-xs" role="button">Documentation</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endif -%}
|
||||
{%- endif %}
|
||||
{% if 'mailhog' in installed_extras -%}
|
||||
{% macro servername() %}{{ vagrant_hostname }}:8025{% endmacro %}
|
||||
{%- if servername() != ":8025" -%}
|
||||
<tr>
|
||||
<th>MailHog</th>
|
||||
<td><a href="http://{{ servername() }}">{{ servername() }}</a>
|
||||
</br>
|
||||
<a href="http://{{ servername() }}" class="btn btn-success btn-xs" role="button">Open</a>
|
||||
<a href="http://docs.drupalvm.com/en/latest/extras/mailhog/" target="_blank" class="btn btn-info btn-xs" role="button">Documentation</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endif -%}
|
||||
{%- endif %}
|
||||
{% if 'pimpmylog' in installed_extras -%}
|
||||
{% macro servername() %}{{ getServernameFromDocroot(pimpmylog_install_dir) }}{% endmacro %}
|
||||
{%- if servername() -%}
|
||||
<tr>
|
||||
<th>PimpMyLog</th>
|
||||
<td><a href="http://{{ servername() }}">{{ servername() }}</a>
|
||||
</br>
|
||||
<a href="http://{{ servername() }}" class="btn btn-success btn-xs" role="button">Open</a>
|
||||
<a href="http://docs.drupalvm.com/en/latest/extras/pimpmylog/" target="_blank" class="btn btn-info btn-xs" role="button">Documentation</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endif -%}
|
||||
{%- endif %}
|
||||
{% if 'solr' in installed_extras -%}
|
||||
{% macro servername() %}{{ vagrant_hostname }}:{{ solr_port }}/solr/{% endmacro %}
|
||||
<tr>
|
||||
<th>Solr</th>
|
||||
<td><a href="http://{{ servername() }}">{{ servername() }}</a>
|
||||
</br>
|
||||
<a href="http://{{ servername() }}" class="btn btn-success btn-xs" role="button">Open</a>
|
||||
<a href="http://docs.drupalvm.com/en/latest/extras/solr/" target="_blank" class="btn btn-info btn-xs" role="button">Documentation</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endif %}
|
||||
{% if 'xhprof' in installed_extras -%}
|
||||
{% macro servername() %}{{ getServernameFromDocroot(php_xhprof_html_dir) }}{% endmacro %}
|
||||
{%- if servername() -%}
|
||||
<tr>
|
||||
<th>XHProf</th>
|
||||
<td><a href="http://{{ servername() }}">{{ servername() }}</a>
|
||||
</br>
|
||||
<a href="http://{{ servername() }}" class="btn btn-success btn-xs" role="button">Open</a>
|
||||
<a href="http://docs.drupalvm.com/en/latest/extras/xhprof/" target="_blank" class="btn btn-info btn-xs" role="button">Documentation</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endif -%}
|
||||
{%- endif %}
|
||||
</table>
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro sectionPhpInformation() -%}
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>PHP Version</th>
|
||||
<td><code>{{ php_version }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Webserver</th>
|
||||
<td><code>{{ drupalvm_webserver|capitalize }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Memory limit</th>
|
||||
<td><code>{{ php_memory_limit }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>PHP-FPM enabled</th>
|
||||
<td><code>{{ 'yes' if php_enable_php_fpm else 'no' }}</code></td>
|
||||
</tr>
|
||||
<tr><td colspan=2><small><a href="/server-info.php">View more details in the server's phpinfo() report</a>.</small></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro sectionDatabaseConnection() -%}
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>MySQL Hostname</th>
|
||||
<td><code>127.0.0.1</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>MySQL Port</th>
|
||||
<td><code>{{ mysql_port }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>MySQL Username</th>
|
||||
<td><code>{{ mysql_root_username }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>MySQL Password</th>
|
||||
<td><code>{{ mysql_root_password }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SSH Hostname</th>
|
||||
<td><code>{{ vagrant_ip }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SSH Username</th>
|
||||
<td><code>{{ vagrant_user }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SSH Private Key</th>
|
||||
<td><code>~/.vagrant.d/insecure_private_key</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro sectionDatabaseList() -%}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<tbody>
|
||||
{% for database in mysql_databases -%}
|
||||
{% if 'adminer' in installed_extras -%}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="http://{{ getServernameFromDocroot(adminer_install_dir) }}/{{ adminer_install_filename }}?username={{ mysql_root_username }}&db={{ database.name }}" class="btn btn-success btn-xs" role="button">{{ database.name }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else -%}
|
||||
<tr>
|
||||
<td>{{ database.name }}</td>
|
||||
</tr>
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro SectionDatabaseListLabel() -%}
|
||||
{% if 'adminer' in installed_extras -%}
|
||||
Databases using Adminer
|
||||
{% else -%}
|
||||
Databases
|
||||
{%- endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro sectionDatabaseUserList() -%}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Password</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in mysql_users -%}
|
||||
<tr>
|
||||
<td><code>{{ user.name }}</code></td>
|
||||
<td><code>{{ user.password }}</code></td>
|
||||
</tr>
|
||||
{%- endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<section class="jumbotron text-center">
|
||||
<a href="https://www.drupalvm.com/"><img src="http://docs.drupalvm.com/en/latest/images/drupal-vm-logo.png" alt="Drupal VM" title="Welcome to Drupal VM" class="img-responsive center-block"></a>
|
||||
<p><a href="https://github.com/geerlingguy/drupal-vm">Drupal VM</a> is a VM for local Drupal development, built with Vagrant + Ansible.</p>
|
||||
<p><a class="btn btn-primary btn-lg" href="http://docs.drupalvm.com/en/latest/" role="button">Read the documentation</a></p>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-heading">Your sites</div>
|
||||
<div class="panel-body">
|
||||
{{ sectionSiteList() }}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-heading"> {{ SectionDatabaseListLabel() }}</div>
|
||||
<div class="panel-body">
|
||||
{{ sectionDatabaseList() }}
|
||||
|
||||
{{ sectionDatabaseUserList() }}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-heading">PHP information</div>
|
||||
<div class="panel-body">
|
||||
{{ sectionPhpInformation() }}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-heading">MySQL connection information</div>
|
||||
<div class="panel-body">
|
||||
{{ sectionDatabaseConnection() }}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-heading">Development tools</div>
|
||||
<div class="panel-body">
|
||||
{{ sectionDevelopmentTools() }}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-heading">/etc/hosts</div>
|
||||
<div class="panel-body">
|
||||
<section class="well small">
|
||||
{{ sectionHost() }}
|
||||
</section>
|
||||
<small>Unless you're using the <a href="https://github.com/cogitatio/vagrant-hostsupdater" target="_blank">vagrant-hostsupdater</a> or <a href="https://github.com/smdahlen/vagrant-hostmanager" target="_blank">vagrant-hostmanager</a> plugin, add the lines above to your host machine's hosts file.</small>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Drupal VM drush aliases.
|
||||
*
|
||||
* @see example.aliases.drushrc.php.
|
||||
*/
|
||||
|
||||
{% macro alias(host, root) -%}
|
||||
{%- if root not in _devtool_docroots %}
|
||||
$aliases['{{ host }}'] = array(
|
||||
'uri' => '{{ host }}',
|
||||
'root' => '{{ root }}',
|
||||
);
|
||||
|
||||
{% endif -%}
|
||||
{% endmacro -%}
|
||||
|
||||
{% block aliases -%}
|
||||
{%- if drupalvm_webserver == 'apache' -%}
|
||||
{%- for vhost in apache_vhosts -%}
|
||||
{{ alias(vhost.servername, vhost.documentroot) }}
|
||||
{%- if vhost.serveralias is defined -%}
|
||||
{%- for serveralias in vhost.serveralias.split() -%}
|
||||
{{ alias(serveralias, vhost.documentroot) }}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- elif drupalvm_webserver == 'nginx' -%}
|
||||
{%- for host in nginx_vhosts -%}
|
||||
{%- for server_name in host.server_name.split() -%}
|
||||
{{ alias(server_name, host.root) }}
|
||||
{%- endfor -%}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endblock %}
|
42
box/provisioning/templates/drupalvm.aliases.drushrc.php.j2
Normal file
42
box/provisioning/templates/drupalvm.aliases.drushrc.php.j2
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Drupal VM drush aliases.
|
||||
*
|
||||
* @see example.aliases.drushrc.php.
|
||||
*/
|
||||
|
||||
{% macro alias(host, root) -%}
|
||||
{%- if root not in _devtool_docroots %}
|
||||
$aliases['{{ host }}'] = array(
|
||||
'uri' => '{{ host }}',
|
||||
'root' => '{{ root }}',
|
||||
'remote-host' => '{{ host }}',
|
||||
'remote-user' => '{{ vagrant_user }}',
|
||||
'ssh-options' => '-o "SendEnv PHP_IDE_CONFIG PHP_OPTIONS XDEBUG_CONFIG" -o PasswordAuthentication=no -i "' . (getenv('VAGRANT_HOME') ?: drush_server_home() . '/.vagrant.d') . '/insecure_private_key"',
|
||||
'path-aliases' => array(
|
||||
'%drush-script' => '{{ drush_path }}',
|
||||
),
|
||||
);
|
||||
|
||||
{% endif -%}
|
||||
{% endmacro -%}
|
||||
|
||||
{% block aliases -%}
|
||||
{%- if drupalvm_webserver == 'apache' -%}
|
||||
{%- for vhost in apache_vhosts -%}
|
||||
{{ alias(vhost.servername, vhost.documentroot) }}
|
||||
{%- if vhost.serveralias is defined -%}
|
||||
{%- for serveralias in vhost.serveralias.split() -%}
|
||||
{{ alias(serveralias, vhost.documentroot) }}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- elif drupalvm_webserver == 'nginx' -%}
|
||||
{%- for host in nginx_vhosts -%}
|
||||
{%- for server_name in host.server_name.split() -%}
|
||||
{{ alias(server_name, host.root) }}
|
||||
{%- endfor -%}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endblock %}
|
180
box/provisioning/templates/drupalvm.vcl.j2
Normal file
180
box/provisioning/templates/drupalvm.vcl.j2
Normal file
|
@ -0,0 +1,180 @@
|
|||
{% block version -%}
|
||||
vcl 4.0;
|
||||
{% endblock %}
|
||||
|
||||
# This Varnish VCL has been adapted from the Four Kitchens VCL for Varnish 3.
|
||||
|
||||
# Default backend definition. Points to Apache, normally.
|
||||
backend default {
|
||||
{% block backend -%}
|
||||
.host = "{{ varnish_default_backend_host }}";
|
||||
.port = "{{ varnish_default_backend_port }}";
|
||||
.first_byte_timeout = 300s;
|
||||
{% endblock %}
|
||||
|
||||
}
|
||||
|
||||
# Access control list for PURGE requests.
|
||||
acl purge {
|
||||
{% block acl_purge -%}
|
||||
"127.0.0.1";
|
||||
{% endblock %}
|
||||
|
||||
}
|
||||
|
||||
# Respond to incoming requests.
|
||||
sub vcl_recv {
|
||||
{% block http_header -%}
|
||||
# Add an X-Forwarded-For header with the client IP address.
|
||||
if (req.restarts == 0) {
|
||||
if (req.http.X-Forwarded-For) {
|
||||
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
|
||||
}
|
||||
else {
|
||||
set req.http.X-Forwarded-For = client.ip;
|
||||
}
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block method_purge -%}
|
||||
# Only allow PURGE requests from IP addresses in the 'purge' ACL.
|
||||
if (req.method == "PURGE") {
|
||||
if (!client.ip ~ purge) {
|
||||
return (synth(405, "Not allowed."));
|
||||
}
|
||||
return (purge);
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block method_ban -%}
|
||||
# Only allow BAN requests from IP addresses in the 'purge' ACL.
|
||||
if (req.method == "BAN") {
|
||||
# Same ACL check as above:
|
||||
if (!client.ip ~ purge) {
|
||||
return (synth(403, "Not allowed."));
|
||||
}
|
||||
|
||||
# Logic for the ban, using the Cache-Tags header. For more info
|
||||
# see https://github.com/geerlingguy/drupal-vm/issues/397.
|
||||
if (req.http.Cache-Tags) {
|
||||
ban("obj.http.Cache-Tags ~ " + req.http.Cache-Tags);
|
||||
}
|
||||
else {
|
||||
return (synth(403, "Cache-Tags header missing."));
|
||||
}
|
||||
|
||||
# Throw a synthetic page so the request won't go to the backend.
|
||||
return (synth(200, "Ban added."));
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block pass_post -%}
|
||||
# Only cache GET and HEAD requests (pass through POST requests).
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return (pass);
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block pass_admin -%}
|
||||
# Pass through any administrative or AJAX-related paths.
|
||||
if (req.url ~ "^/status\.php$" ||
|
||||
req.url ~ "^/update\.php$" ||
|
||||
req.url ~ "^/admin$" ||
|
||||
req.url ~ "^/admin/.*$" ||
|
||||
req.url ~ "^/flag/.*$" ||
|
||||
req.url ~ "^.*/ajax/.*$" ||
|
||||
req.url ~ "^.*/ahah/.*$") {
|
||||
return (pass);
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block cookies -%}
|
||||
# Removing cookies for static content so Varnish caches these files.
|
||||
if (req.url ~ "(?i)\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$") {
|
||||
unset req.http.Cookie;
|
||||
}
|
||||
|
||||
# Remove all cookies that Drupal doesn't need to know about. We explicitly
|
||||
# list the ones that Drupal does need, the SESS and NO_CACHE. If, after
|
||||
# running this code we find that either of these two cookies remains, we
|
||||
# will pass as the page cannot be cached.
|
||||
if (req.http.Cookie) {
|
||||
# 1. Append a semi-colon to the front of the cookie string.
|
||||
# 2. Remove all spaces that appear after semi-colons.
|
||||
# 3. Match the cookies we want to keep, adding the space we removed
|
||||
# previously back. (\1) is first matching group in the regsuball.
|
||||
# 4. Remove all other cookies, identifying them by the fact that they have
|
||||
# no space after the preceding semi-colon.
|
||||
# 5. Remove all spaces and semi-colons from the beginning and end of the
|
||||
# cookie string.
|
||||
set req.http.Cookie = ";" + req.http.Cookie;
|
||||
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
|
||||
set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=", "; \1=");
|
||||
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
|
||||
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
|
||||
|
||||
if (req.http.Cookie == "") {
|
||||
# If there are no remaining cookies, remove the cookie header. If there
|
||||
# aren't any cookie headers, Varnish's default behavior will be to cache
|
||||
# the page.
|
||||
unset req.http.Cookie;
|
||||
}
|
||||
else {
|
||||
# If there is any cookies left (a session or NO_CACHE cookie), do not
|
||||
# cache the page. Pass it on to Apache directly.
|
||||
return (pass);
|
||||
}
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
}
|
||||
|
||||
# Set a header to track a cache HITs and MISSes.
|
||||
sub vcl_deliver {
|
||||
{% block vcl_deliver -%}
|
||||
# Remove ban-lurker friendly custom headers when delivering to client.
|
||||
unset resp.http.X-Url;
|
||||
unset resp.http.X-Host;
|
||||
unset resp.http.Purge-Cache-Tags;
|
||||
|
||||
if (obj.hits > 0) {
|
||||
set resp.http.X-Varnish-Cache = "HIT";
|
||||
}
|
||||
else {
|
||||
set resp.http.X-Varnish-Cache = "MISS";
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
}
|
||||
|
||||
# Instruct Varnish what to do in the case of certain backend responses (beresp).
|
||||
sub vcl_backend_response {
|
||||
{% block vcl_backend_response -%}
|
||||
# Set ban-lurker friendly custom headers.
|
||||
set beresp.http.X-Url = bereq.url;
|
||||
set beresp.http.X-Host = bereq.http.host;
|
||||
|
||||
# Cache 404s, 301s, at 500s with a short lifetime to protect the backend.
|
||||
if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {
|
||||
set beresp.ttl = 10m;
|
||||
}
|
||||
|
||||
# Enable streaming directly to backend for BigPipe responses.
|
||||
if (beresp.http.Surrogate-Control ~ "BigPipe/1.0") {
|
||||
set beresp.do_stream = true;
|
||||
set beresp.ttl = 0s;
|
||||
}
|
||||
|
||||
# Don't allow static files to set cookies.
|
||||
# (?i) denotes case insensitive in PCRE (perl compatible regular expressions).
|
||||
# This list of extensions appears twice, once here and again in vcl_recv so
|
||||
# make sure you edit both and keep them equal.
|
||||
if (bereq.url ~ "(?i)\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$") {
|
||||
unset beresp.http.set-cookie;
|
||||
}
|
||||
|
||||
# Allow items to remain in cache up to 6 hours past their cache expiration.
|
||||
set beresp.grace = 6h;
|
||||
{% endblock %}
|
||||
|
||||
}
|
143
box/provisioning/templates/nginx-vhost.conf.j2
Normal file
143
box/provisioning/templates/nginx-vhost.conf.j2
Normal file
|
@ -0,0 +1,143 @@
|
|||
{% block server_redirect -%}
|
||||
{% if item.server_name_redirect is defined -%}
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ item.server_name_redirect }};
|
||||
return 301 $scheme://{{ item.server_name.split(' ')[0] }}$request_uri;
|
||||
}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
server {
|
||||
{% block server_begin -%}{% endblock %}
|
||||
|
||||
{% block server_basic -%}
|
||||
listen {{ item.listen | default('80') }};
|
||||
server_name {{ item.server_name }};
|
||||
root {{ item.root }};
|
||||
index {{ item.index | default('index.php index.html index.htm') }};
|
||||
{% endblock %}
|
||||
|
||||
{% block server_logs -%}
|
||||
{%- if item.access_log is defined -%}
|
||||
access_log {{ item.access_log }};
|
||||
{%- endif -%}
|
||||
error_log {{ item.error_log|default('/var/log/nginx/error.log') }} info;
|
||||
{% endblock %}
|
||||
|
||||
{% if item.is_php is defined and item.is_php %}
|
||||
{% block location_primary -%}
|
||||
location / {
|
||||
# Don't touch PHP for static content.
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block location_deny -%}
|
||||
# Don't allow direct access to PHP files in the vendor directory.
|
||||
location ~ /vendor/.*\.php$ {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
# Allow "Well-Known URIs" as per RFC 5785
|
||||
location ~* ^/.well-known/ {
|
||||
allow all;
|
||||
}
|
||||
location ~ (^|/)\. {
|
||||
return 403;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block location_drupal_legacy -%}
|
||||
{% if drupal_major_version == 8 -%}
|
||||
# Redirect common PHP files to their new locations.
|
||||
location ~ ^((?!.*(?:core)).*)/(install.php|rebuild.php) {
|
||||
return 301 $scheme://$host$1/core/$2$is_args$args;
|
||||
}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block location_php -%}
|
||||
# Use fastcgi for all php files.
|
||||
location ~ \.php$|^/update.php {
|
||||
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_read_timeout {{ php_max_execution_time }};
|
||||
include fastcgi_params;
|
||||
fastcgi_pass {{ php_fpm_listen }};
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block location_rewrite -%}
|
||||
location @rewrite {
|
||||
rewrite ^ /index.php;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block location_image_styles -%}
|
||||
location ~ ^/sites/.*/files/styles/ {
|
||||
try_files $uri @rewrite;
|
||||
}
|
||||
location ~ ^(/[a-z\-]+)?/system/files/ {
|
||||
try_files $uri /index.php?$query_string;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block location_favicon -%}
|
||||
location = /favicon.ico {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block location_robots -%}
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block location_assets -%}
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
|
||||
expires max;
|
||||
log_not_found off;
|
||||
}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
{% block server_compression -%}
|
||||
gzip on;
|
||||
gzip_proxied any;
|
||||
gzip_static on;
|
||||
gzip_http_version 1.0;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
gzip_vary on;
|
||||
gzip_comp_level 6;
|
||||
gzip_types
|
||||
text/plain
|
||||
text/css
|
||||
text/xml
|
||||
text/javascript
|
||||
application/javascript
|
||||
application/x-javascript
|
||||
application/json
|
||||
application/xml
|
||||
application/xml+rss
|
||||
application/xhtml+xml
|
||||
application/x-font-ttf
|
||||
application/x-font-opentype
|
||||
image/svg+xml
|
||||
image/x-icon;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_min_length 512;
|
||||
{% endblock %}
|
||||
|
||||
{% block server_end -%}{% endblock %}
|
||||
|
||||
{% if item.extra_parameters is defined -%}
|
||||
{{ item.extra_parameters|indent(4) }}
|
||||
{%- endif %}
|
||||
}
|
1
box/provisioning/templates/server-info.php.j2
Normal file
1
box/provisioning/templates/server-info.php.j2
Normal file
|
@ -0,0 +1 @@
|
|||
<?php phpinfo(); ?>
|
Loading…
Add table
Add a link
Reference in a new issue