Skip to content

Instantly share code, notes, and snippets.

@Twipped
Created February 28, 2012 22:17
Show Gist options
  • Select an option

  • Save Twipped/1935628 to your computer and use it in GitHub Desktop.

Select an option

Save Twipped/1935628 to your computer and use it in GitHub Desktop.
Primal nginx server configuration.
server {
listen 80;
server_name www.primal.dev primal.dev;
access_log /srv/www/primal.dev/log/access.log;
error_log /srv/www/primal.dev/log/error.log;
root /srv/www/primal.dev/www;
index index.html index.htm index.php;
# force www subdomain
if ($host !~* ^(www)) {
rewrite ^/(.*)$ $scheme://www.$host/$1 permanent;
}
# turn off logging for robots.txt and favicon.png
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.png { access_log off; log_not_found off; }
# prevent serving of hidden files (ie, .gitignore)
location ~ /\. { access_log off; log_not_found off; deny all; }
# any requests to files inside Primal protected folders should be passed to Primal
location ~ /(cache|classes|views|actions) {
rewrite ^ /main.php last;
}
# request for root gets passed directly to Primal
location = / {
rewrite ^ /main.php last;
}
# request for anything that doesn't exist, of if the user is requesting /myadmin/ and isn't from an approved IP, pass it to Primal
location / {
if (!-e $request_filename) {
rewrite ^ /main.php last;
}
}
# send all php requests to fastcgi
location ~ \.php$ {
try_files $uri $uri/ $uri/index.php /main.php;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment