forked from mendix/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
119 lines (96 loc) · 3.18 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copy from https://github.com/cloudfoundry/staticfile-buildpack/blob/master/conf/nginx.conf, making sure Jekyll urls are served correctly
worker_processes 1;
daemon off;
error_log <%= ENV["APP_ROOT"] %>/nginx/logs/error.log;
events { worker_connections 1024; }
http {
charset utf-8;
log_format cloudfoundry '$http_x_forwarded_for - $http_referer - [$time_local] "$request" $status $body_bytes_sent';
access_log <%= ENV["APP_ROOT"] %>/nginx/logs/access.log cloudfoundry;
default_type application/octet-stream;
include mime.types;
sendfile on;
rewrite_log on;
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gunzip on;
gzip_static always;
gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss;
tcp_nopush on;
keepalive_timeout 30;
port_in_redirect off; # Ensure that redirects don't include the internal container PORT - <%= ENV["PORT"] %>
server_tokens off;
map_hash_bucket_size 256;
# Mappings for indexes
map $request_uri $index_uri {
include <%= ENV["APP_ROOT"] %>/public/mappings/indexes.map;
}
# Mappings for redirects, generated by `gulp write:mappings` from _assets folder
map $request_uri $new_uri {
include <%= ENV["APP_ROOT"] %>/public/mappings/redirect.map;
}
server {
listen <%= ENV["PORT"] %>;
server_name localhost;
root <%= ENV["APP_ROOT"] %>/public;
<% if ENV["FORCE_HTTPS"] %>
if ($http_x_forwarded_proto != "https") {
return 301 https://$host$request_uri;
}
<% end %>
# Index redirect
if ($index_uri) {
return 301 https://$host$index_uri;
}
# Redirects
if ($new_uri) {
return 301 https://$host$new_uri;
}
# GENERIC URLS FOR REFGUIDE & HOWTO. Set as 301
location ~ ^/refguide/ {
rewrite ^/refguide/(.*)$ https://$host/refguide7/$1 redirect;
}
location ~ ^/howto/ {
rewrite ^/howto/(.*)$ https://$host/howto7/$1 redirect;
}
index index.html index.htm Default.htm;
error_page 404 /404.html;
location = /404.html {
internal;
}
location ~ \.html$ {
rewrite ^(.*)\.html$ https://$host$1 permanent;
}
# Moved old mxsupport links to /support
location ~ ^/mxsupport {
rewrite ^/mxsupport/(.*)$ https://$host/howtogeneral/support/$1 permanent;
}
# Move apidocs to new url
location = /apidocs/ {
rewrite ^/(.*)/$ https://$host/apidocs-mxsdk/apidocs/ redirect;
}
location / {
rewrite ^(.*/)\index(\?.*)?$ $1$2 permanent;
try_files $uri/index.html $uri.html $uri/ $uri =404;
}
# Expiration for attachments set to 1 year
location ~ /attachments/ {
expires 1y;
try_files $uri/index.html $uri.html $uri/ $uri =404;
}
# Expiration for menu jsons set to 1 hour
location /json/ {
expires 1h;
try_files $uri/index.html $uri.html $uri/ $uri =404;
}
# Expiration set for assets to 1 month (TODO: could be longer due to cache string)
location /public/ {
expires 1M;
try_files $uri/index.html $uri.html $uri/ $uri =404;
}
}
}