-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp_nginx.conf
104 lines (88 loc) · 2.89 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
97
98
99
100
101
102
103
104
#
# 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 gzip settings
#
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_min_length 1500;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
#
# Allow large file uploads
#
client_max_body_size 64m;
client_body_temp_path /tmp;
# client_max_body_size 16M;
#
# 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/ $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;
}
rewrite ^/(wp-admin|wp-includes|wp-login.php|xmlrpc.php|wp-cron.php)(.*)$ /wp/$1$2 last;
# 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 SERVER_PORT $http_x_forwarded_port;
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 SERVER_PORT $http_x_forwarded_port;
fastcgi_param HTTPS $https_forwarded if_not_empty;
# Execute PHP
fastcgi_pass heroku-fcgi;
}