-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.nginx.conf
66 lines (52 loc) · 1.82 KB
/
sample.nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
server {
listen 80;
server_name example.com;
root /var/www/example.com/public/;
ssl_protocols TLSv1.2;
index index.html index.htm index.php;
charset utf-8;
# Dynamically set the try_files locations.
# Statically cached files should only be loaded for GET requests.
set $try_files @default;
if ($request_method = GET) {
set $try_files @static;
}
# The files to try when its a potentially static cache request (ie. a GET request)
location @static {
try_files /static${uri}_${query_string}.html @default;
}
# The files to try when it's not a static cache request (ie. anything other than GET)
location @default {
try_files $uri $uri/ /index.php?$query_string;
}
location / {
try_files $uri $try_files; # Use the dynamically assigned locations from above.
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/example.com-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# Block access to hidden files (except the /.well-known/ dir)
location ~ /(?!.well-known)(\.)\w+ {
deny all;
}
# Block access to Statamic, content, and cache locations
location ~ ^\/(statamic|local|(site\/(?!themes))) {
deny all;
return 404;
}
# Enable gzip compression
# gzip on;
# gzip_min_length 1100;
# gzip_buffers 4 32k;
# gzip_types text/plain application/x-javascript text/xml text/css;
# gzip_vary on;
}