Switch to new vhost management

pull/2/head
Emilien Mantel 2015-07-30 15:37:25 +02:00
parent ec94521c5b
commit 67d220e39f
10 changed files with 46 additions and 104 deletions

View File

@ -1,32 +0,0 @@
{% set server_name = [ item.name ] %}
{% set aliases = item.aliases if item.aliases is defined else [] %}
{% set ignore = server_name.extend(aliases) %}
{% if item.ssl is defined and item.ssl.use is defined and item.ssl.use %}
listen {{ item.listen | default('443') }};
server_name {{ server_name | join(' ') }};
ssl on;
ssl_certificate {{ nginx_ssl_dir }}/{{ item.name }}/{{ item.name }}.crt;
ssl_certificate_key {{ nginx_ssl_dir }}/{{ item.name }}/{{ item.name }}.key;
include /etc/nginx/helpers/ssl-{{ item.ssl.template | default('strong') }};
{% else %}
listen {{ item.listen | default('80') }};
server_name {{ server_name | join(' ') }};
{% endif %}
{% if item.root is defined %}
root {{ item.root }};
{% else %}
root {{ nginx_root }}/{{ item.name }}/public;
{% endif %}
{% if item.use_access_log is defined and item.use_access_log %}
access_log {{ nginx_log_dir }}/{{ item.name }}_access.log combined;
{% else %}
access_log off;
{% endif %}
{% if item.use_error_log is defined and item.use_error_log %}
error_log {{ nginx_log_dir }}/{{ item.name }}_error.log {{ nginx_error_log_level }};
{% else %}
error_log off;
{% endif %}

View File

@ -1,6 +0,0 @@
{% if item.redirect_server_name is defined %}
server {
server_name {{ item.redirect_server_name | join(' ') }};
return 301 {% if item.ssl.use %}https{% else %}http{% endif %}://{{ item.server_name[0] }}$request_uri;
}
{% endif %}

View File

@ -12,13 +12,11 @@ server {
listen {{ port }};
{% endfor %}
server_name {{ item.name | join(' ') }};
{% if item.root is defined %}
root {{ item.root }};
{% else %}
root {{ nginx_root }}/{{ item.name[0] }}/public;
{% endif %}
{% block template_index %}
index {{ item.index | default('index.html index.htm') }};
{% endblock %}
@ -27,13 +25,22 @@ server {
try_files $uri $uri/ =404;
{% endblock %}
{% block template_upstream_location %}
{% endblock %}
{% block template_custom_location %}
{% endblock %}
location ~ /\.ht {
deny all;
}
location ~* \.(txt|js|css|png|jpg|jpeg|gif|ico|svg)$ {
location = /favicon.ico {
expires 30d;
access_log off;
log_not_found off;
}
location ~* \.(txt|js|css|png|jpe?g|gif|ico|svg)$ {
expires 30d;
log_not_found off;
}
@ -50,6 +57,14 @@ server {
{% endif %}
}
{#
ssl on;
ssl_certificate {{ nginx_ssl_dir }}/{{ item.name }}/{{ item.name }}.crt;
ssl_certificate_key {{ nginx_ssl_dir }}/{{ item.name }}/{{ item.name }}.key;
include /etc/nginx/helpers/ssl-{{ item.ssl.template | default('strong') }};
#}
# HTTPS
#server {
#}

View File

@ -0,0 +1,22 @@
{% extends "_php.j2" %}
{% block template_index %}
index doku.php;
{% endblock %}
{% block template_try_files %}
try_files $uri $uri/ @dokuwiki =404;
{% endblock %}
{% block template_custom_location %}
location @dokuwiki {
rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
rewrite ^/(.*) /doku.php?id=$1 last;
}
location ~ /(data|conf|bin|inc)/ {
deny all;
}
{% endblock %}

View File

@ -7,7 +7,7 @@
try_files $uri $uri/ index.php;
{% endblock %}
{% block template_custom_location %}
{% block template_upstream_location %}
location ~ \.php$ {
fastcgi_pass php;
fastcgi_index index.php;

View File

@ -0,0 +1,5 @@
{% extends "_php.j2" %}
{% block template_try_files %}
try_files $uri $uri/ index.php?$args;
{% endblock %}

View File

@ -1,19 +0,0 @@
#
# {{ ansible_managed }}
#
server {
{% include 'COMMON.j2' %}
index index.htm index.html index.php;
location / {
try_files $uri $uri/ /index.php;
}
include /etc/nginx/helpers/php;
include /etc/nginx/helpers/no-ht;
include /etc/nginx/helpers/static-expires;
}
{% include 'REDIRECT.j2' %}
# vim:filetype=nginx

View File

@ -1,19 +0,0 @@
#
# {{ ansible_managed }}
#
server {
{% include 'COMMON.j2' %}
index index.htm index.html;
location / {
try_files $uri $uri/ =404;
}
include /etc/nginx/helpers/static-expires;
include /etc/nginx/helpers/no-ht;
}
{% include 'REDIRECT.j2' %}
# vim:filetype=nginx

View File

@ -1,20 +0,0 @@
#
# {{ ansible_managed }}
#
server {
{% include 'COMMON.j2' %}
index index.htm index.html index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
include /etc/nginx/helpers/static-expires;
include /etc/nginx/helpers/no-ht;
include /etc/nginx/helpers/php;
}
{% include 'REDIRECT.j2' %}
# vim:filetype=nginx

View File

@ -18,13 +18,9 @@
- 'test-alias.local'
- 'test2-alias.local'
template: '_base'
ssl:
use: false
- name:
- 'test-php.local'
template: '_php'
ssl:
use: false
roles:
- ../../
post_tasks: