diff --git a/README.md b/README.md index e19da5b..836b8af 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,18 @@ A list of vhost definitions (server blocks) for Nginx virtual hosts. If left emp error_log: "" extra_parameters: | location ~ \.php$ { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/var/run/php5-fpm.sock; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } An example of a fully-populated nginx_vhosts entry, using a `|` to declare a block of syntax for the `extra_parameters`. +Please take note of the indentation in the above block. The first line should be a normal 2-space indent, with everything else 4-space indented, relative to the first line. +Following this style will ensure the config file is indented correctly. + nginx_remove_default_vhost: false Whether to remove the 'default' virtualhost configuration supplied by Nginx. Useful if you want the base `/` URL to be directed at one of your own virtual hosts configured in a separate .conf file. diff --git a/templates/vhosts.j2 b/templates/vhosts.j2 index 04dbf9e..454ca2b 100644 --- a/templates/vhosts.j2 +++ b/templates/vhosts.j2 @@ -2,32 +2,32 @@ server { listen {{ vhost.listen | default('80 default_server') }}; - {% if vhost.server_name is defined %} +{% if vhost.server_name is defined %} server_name {{ vhost.server_name }}; - {% endif %} +{% endif %} - {% if vhost.root is defined %} +{% if vhost.root is defined %} root {{ vhost.root }}; - {% endif %} +{% endif %} index {{ vhost.index | default('index.html index.htm') }}; - {% if vhost.error_page is defined %} +{% if vhost.error_page is defined %} error_page {{ vhost.error_page }}; - {% endif %} - {% if vhost.access_log is defined %} +{% endif %} +{% if vhost.access_log is defined %} access_log {{ vhost.access_log }}; - {% endif %} - {% if vhost.error_log is defined %} +{% endif %} +{% if vhost.error_log is defined %} error_log {{ vhost.error_log }} error; - {% endif %} +{% endif %} - {% if vhost.return is defined %} +{% if vhost.return is defined %} return {{ vhost.return }}; - {% endif %} +{% endif %} - {% if vhost.extra_parameters is defined %} +{% if vhost.extra_parameters is defined %} {{ vhost.extra_parameters }} - {% endif %} +{% endif %} } {% endfor %}