Skip to content

Commit

Permalink
Prepares catchall for php
Browse files Browse the repository at this point in the history
  • Loading branch information
bravo-kernel committed Nov 23, 2014
1 parent 6025b40 commit 868ad25
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
3 changes: 2 additions & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
source node['cakebox']['nginx']['default_site']
path "/etc/nginx/sites-available/default"
variables(
:root => node['cakebox']['nginx']['catchall_webroot']
:root => node['cakebox']['nginx']['catchall_webroot'],
:timestamp => Time.now.strftime("%Y-%m-%d %H:%M:%S")
)
notifies :reload, "service[nginx]", :immediately
end
Expand Down
40 changes: 27 additions & 13 deletions templates/default/nginx-default-site.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#
# Default site configuration.
#
# Generated by chef-cakebox at <%= @timestamp %>.
#
server {
listen 80 default_server;
server_name _;
root <%= @root %>;
listen 80 default_server;
server_name _;

index index.php index.html index.htm;
# root directive should be global
root <%= @root %>;
index index.php index.htm;

location / {
try_files $uri $uri/ / =404;
}
access_log /var/log/nginx/default.access.log;
error_log /var/log/nginx/default.error.log;

# Deny access to .htaccess & .htpasswd files
location ~ /\.ht {
deny all;
}
location / {
try_files $uri \$uri/ /index.php?\$args;
}

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log error;
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

# deny access to hidden
location ~ /\. {
deny all;
}
}

0 comments on commit 868ad25

Please sign in to comment.