forked from CanonicalLtd/maas-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
64 lines (50 loc) · 1.42 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
map $http_x_forwarded_proto $url_prefix {
default $scheme://$http_host;
https https://$http_host;
http http://$http_host;
}
map $uri $target {
include redirects.map;
}
server {
listen 8203 default_server;
listen [::]:8203 default_server;
server_name _;
# Log to stdout
access_log /dev/stdout;
error_log /dev/stderr info;
root /srv;
index index.html;
# Show 404 page
error_page 404 /404.html;
# Show commit-id
add_header x-vcs-revision ~BUILD_ID~ always;
add_header x-hostname $hostname always;
# Apply redirects from file
if ($target ~* '://') {
rewrite ^ $target redirect;
}
if ($target) {
rewrite ^ $url_prefix$target redirect;
}
# Remove index or index.html from URIs
if ($request_uri ~ ^.*/index$) {
rewrite ^(.*/)index$ $url_prefix$1 permanent;
}
if ($request_uri ~ ^.*/index.html$) {
rewrite ^(.*/)index.html$ $url_prefix$1 permanent;
}
# Remove .html from URIs
if ($request_uri ~ ^.*\.html$) {
rewrite ^(.*)\.html$ $url_prefix$1 permanent;
}
# Remove slashes form URIs if it's not a directory
if (!-d $request_filename) {
rewrite ^(.*)/$ $url_prefix$1 permanent;
}
# Add slashes from URIs if it's a directory
if (-d $request_filename) {
rewrite ^(.*[^/])$ $url_prefix$1/ permanent;
}
try_files $uri $uri.html $uri/ =404;
}