forked from canonical/microk8s.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
43 lines (33 loc) · 1 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
server {
listen 80 default_server;
listen [::]:80 default_server;
root /srv;
index index.html;
# Log to stdout
access_log /dev/stdout;
error_log /dev/stderr info;
# Show 404 page
error_page 404 /404.html;
# Show commit-id
add_header X-Commit-ID ~COMMIT_ID~ always;
add_header X-Hostname $hostname always;
server_name _;
# Remove index or index.html from URIs
if ($request_uri ~ ^.*/index(.html)?$) {
rewrite ^(.*/)index(.html)? $1 permanent;
}
# Remove slashes form URIs if it's not a directory
if (!-d $request_filename) {
rewrite ^/(.*)/$ /$1 permanent;
}
# Add slashes from URIs if it's a directory
if (-d $request_filename) {
rewrite ^/(.*[^/])$ /$1/ permanent;
}
# For finding files from URIs
# First try the URI directly, then try adding .html, then try treating it as a directory
# Finally fall back to 404
location ~ ^/.+$ {
try_files $uri $uri.html $uri/ =404;
}
}