2014-08-27 19:03:34 +02:00
|
|
|
{% set domain_name = item.nginx_domain_name %}
|
|
|
|
{% set domain_aliases = item.nginx_domain_aliases | default("") %}
|
|
|
|
|
2014-08-16 23:35:57 +02:00
|
|
|
server {
|
2014-08-27 19:03:34 +02:00
|
|
|
listen 80;
|
2014-08-16 23:35:57 +02:00
|
|
|
|
2014-08-27 19:03:34 +02:00
|
|
|
root {{ nginx_root_prefix }}/{{ domain_name }};
|
2014-08-16 23:35:57 +02:00
|
|
|
|
2014-08-27 19:03:34 +02:00
|
|
|
server_name {{ domain_name }} {{ domain_aliases }};
|
2014-08-16 23:35:57 +02:00
|
|
|
|
2014-08-27 19:26:12 +02:00
|
|
|
access_log /var/log/nginx/{{ domain_name }}-access.log;
|
|
|
|
error_log /var/log/nginx/{{ domain_name }}-error.log;
|
|
|
|
|
2014-08-16 23:35:57 +02:00
|
|
|
location / {
|
|
|
|
try_files $uri $uri/ =404;
|
|
|
|
}
|
|
|
|
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
|
location = /50x.html {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
}
|
|
|
|
|
|
|
|
location ~ \.php$ {
|
|
|
|
# Zero-day exploit defense.
|
|
|
|
# http://forum.nginx.org/read.php?2,88845,page=3
|
|
|
|
# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
|
|
|
|
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
|
|
|
|
try_files $uri =404;
|
|
|
|
|
|
|
|
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
|
|
|
2014-08-27 19:03:34 +02:00
|
|
|
fastcgi_pass unix:/var/run/php5-fpm-{{ domain_name }}.sock;
|
2014-08-16 23:35:57 +02:00
|
|
|
fastcgi_index index.php;
|
|
|
|
# set script path relative to document root in server block
|
|
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
|
|
include fastcgi_params;
|
|
|
|
}
|
|
|
|
}
|