This repository was archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnginx.example.conf
More file actions
56 lines (42 loc) · 1.32 KB
/
Copy pathnginx.example.conf
File metadata and controls
56 lines (42 loc) · 1.32 KB
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
server {
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
root /var/www/example/public;
server_name example.com;
index index.php;
access_log /var/log/nginx/example.access.log;
error_log /var/log/nginx/example.error.log;
try_files $uri /index.php?$args;
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
}
location ~ /\.ht { deny all; }
}
server {
root /var/www/example/static;
server_name static.example.com;
index index.html;
access_log off;
error_log /var/log/nginx/example.static.error.log;
log_not_found off;
try_files $uri =404;
# Maybe limit a bit better...
add_header Access-Control-Allow-Origin '*';
# Disallow accessing origs without the fake filename and any php files as a failsafe
location ~ ^/file/([a-z0-9]+)/o/([a-z0-9]+)(\.\w+)$ { return 404; }
location ~ \.php$ { return 404; }
location ~ ^/(css|img|js)/ {
expires max;
}
location /file/ {
expires max;
# Files do not use query strings.
if ($query_string != '') { return 404; }
# Fake filenames for browsers
rewrite ^/file/([a-z0-9]+)/o/([a-z0-9]+)/(.+)(\.\w+)$ /files/$1/o/$2$4 break;
}
}