-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
73 lines (57 loc) · 1.67 KB
/
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
67
68
69
70
71
72
73
# replace example.com and examplecache
fastcgi_cache_path /var/www/example.com/cache levels=1:2 keys_zone=examplecache:100m inactive=60m;
# Set up 301s from alternative URLs.
server {
listen 80;
listen [::]:80; # handle ipv6.
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
listen [::]:80; # handle ipv6.
server_name example.com;
root /var/www/example.com/htdocs/public;
index index.php index.html index.htm;
client_max_body_size 10M;
# use Google Public DNS.
resolver 8.8.8.8;
##### gzipping #####
gzip on;
gzip_min_length 10;
gzip_comp_level 2;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/javascript text/xml application/javascript application/x-javascript font/truetype font/opentype image/svg+xml;
##### END gzipping #####
# Cache all pages...
set $no_cache 0;
# ...except the admin area.
location /admin {
set $no_cache 1;
}
# Cache non-admin assets
location ~* ^(!/admin/(.*))\.(js|css|png|jpg|jpeg|gif|ico|woff|ttf|svg)(.*)?$ {
expires 1M;
}
location ~ \.php$ {
fastcgi_cache examplecache;
fastcgi_cache_valid 200 1d; # cache 200s for a day.
fastcgi_cache_methods GET HEAD;
add_header X-Fastcgi-Cache $upstream_cache_status;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^(.*)$ {
try_files $uri $uri/ /index.php?p=$uri&$args;
}
location ~ /\.ht {
deny all;
return 404;
}
}