forked from xyu/heroku-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_nginx.conf
96 lines (80 loc) · 2.54 KB
/
app_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#
# Set HTTPS env var if the Heroku router used SSL
#
if ( $http_x_forwarded_proto = https ) {
set $https_forwarded on;
}
#
# Set index files for dirs
#
index index.php index.html index.htm;
#
# Set defaults for all paths not matched more specificaly
#
location = / {
# Unless we have /index.html send '/' directly to WP
try_files index.html @wordpress;
}
location / {
# Serve up real files or send to WP
try_files $uri $uri/ @wordpress;
}
# We don't care if there's no favicon.ico
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Also don't care if there's no robots.txt
location = /robots.txt {
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
deny all;
}
# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
# Setup a special /assets/ dir that is magical
location ^~ /assets/ {
if (!-f $request_filename) {
rewrite ^/assets/[^/]+/(.*)$ /assets/$1 break;
}
access_log off;
log_not_found off;
expires max;
if_modified_since off;
add_header Last-Modified "";
}
# Handle URIs that have .php in it
location ~ \.php {
# Parse file vs. path info parts
fastcgi_split_path_info ^((?U).*\.php)(.*)$;
# Save our path info before trying the file http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
# Make sure file is real otherwise hand it off to WP
try_files $fastcgi_script_name @wordpress;
# Set ENV vars for PHP
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $path_info if_not_empty;
fastcgi_param HTTPS $https_forwarded if_not_empty;
# Execute PHP
fastcgi_pass heroku-fcgi;
}
# Frontend WP
location @wordpress {
# Set ENV vars for PHP
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param HTTPS $https_forwarded if_not_empty;
# Execute PHP
fastcgi_pass heroku-fcgi;
}