Created
October 8, 2012 03:45
-
-
Save monkyz/3850614 to your computer and use it in GitHub Desktop.
silverstripe nginx vhost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a better nginx config | |
02 | |
# author @dnoiz1 | |
03 | |
04 | |
server { | |
05 | |
root /var/www/mysite.tld/; | |
06 | |
server_name mysite.tld www.mysite.tld; | |
07 | |
08 | |
access_log /var/log/nginx/mysite.tld.access.log main; | |
09 | |
error_log /var/log/nginx/mysite.tld.error.log; | |
10 | |
11 | |
location ~* ^.+\.(jpg|jpeg|gif|png|css|zip|pdf|txt|js|flv|swf|html|htm)$ | |
12 | |
{ | |
13 | |
expires max; | |
14 | |
log_not_found off; | |
15 | |
try_files $uri $uri/ /framework/main.php?$uri=$args; | |
16 | |
} | |
17 | |
18 | |
# dont exec scripts in assets etc | |
19 | |
location ~* /assets(.*?)$ { expires max; access_log off; log_not_found off; } | |
20 | |
21 | |
location ~ /\. { deny all; access_log off; log_not_found off; } | |
22 | |
location ~* ^.+\.(log|ss|config)$ { deny all; access_log off; log_not_found off; } | |
23 | |
location ~* /themes/(.*?)$ { expires max; access_log off; log_not_found off; } | |
24 | |
location = /favicon.ico { access_log off; log_not_found off; } | |
25 | |
location = /robots.txt { access_log off; log_not_found off; } | |
26 | |
27 | |
if (!-f $request_filename) { | |
28 | |
rewrite ^/(.*?)(\?|$)(.*)$ /framework/main.php?url=$1&$3 last; | |
29 | |
} | |
30 | |
31 | |
location / { | |
32 | |
# buffer sizes can be upped in fastcgi_params | |
33 | |
include fastcgi_params; | |
34 | |
# a ss site specific worker pool is nice also, using a unix sock instead of localhost tcp | |
35 | |
fastcgi_pass unix:/var/run/php-fpm/mysite.tld.sock; | |
36 | |
fastcgi_index /index.php; | |
37 | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
38 | |
fastcgi_param SCRIPT_NAME $fastcgi_script_name; | |
39 | |
} | |
40 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment