forked from NativeScript/docs-v7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
221 lines (174 loc) · 13.4 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
worker_processes auto;
events {
worker_connections 768;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_disable "msie6";
server {
listen 9192 default_server;
listen [::]:9192 default_server;
set $should_redirect 0;
if ($http_x_forwarded_proto) {
set $should_redirect 1;
}
if ($http_x_forwarded_proto != 'https') {
set $should_redirect "${should_redirect}1";
}
set $hsts "";
if ($http_x_forwarded_proto = 'https') {
set $hsts "max-age=31536000; includeSubDomains";
}
if ($should_redirect = 11) {
return 301 https://$host$request_uri;
}
root /www/docs/build/bin/site;
add_header Strict-Transport-Security $hsts always;
server_name _;
set $host_and_port $host:$server_port;
set $proto http;
if ($http_x_forwarded_proto = "https") {
set $proto https;
set $host_and_port $host;
}
rewrite ^/$ /start/landing.html last;
rewrite ^/(.*)/$ $proto://$host_and_port/$1/start/landing.html permanent;
{% for directory in site.redirect_directories %}
rewrite ^/{{ directory.path }}/?$ $proto://$host_and_port/{{ directory.url }} permanent;
{% endfor %}
{% for page in site.redirect_pages %}
{% for redirect in page.previous_url %}
rewrite ^/{{ redirect | remove_first: '/' }}(\.html)?$ $proto://$host_and_port/{{ page.url | remove_first: '/' | replace: '.html', '' }} permanent;
{% endfor %}
{% endfor %}
rewrite ^/vuejs$ $proto://$host_and_port/vuejs/nativescript-vuejs permanent;
# Redirect old api reference
rewrite (?i)/apireference/(.*)$ $proto://$host_and_port/api-reference permanent;
rewrite ^/api-reference$ $proto://$host_and_port/api-reference/globals permanent;
rewrite ^/angular/api-reference/(.*) $proto://$host_and_port/api-reference/$1 permanent;
rewrite ^/angular/ns-ui-api-reference/(.*) $proto://$host_and_port/ns-ui-api-reference/$1 permanent;
rewrite ^/vuejs/ns-ui-api-reference/(.*) $proto://$host_and_port/ns-ui-api-reference/$1 permanent;
rewrite ^(/.*)?/ns-ui-api-reference$ $proto://$host_and_port/ns-ui-api-reference/globals permanent;
rewrite ^(/.*)?/ng-api-reference$ $proto://$host_and_port/ng-api-reference/globals permanent;
# Redirect runtimes under core concepts
rewrite ^(/angular)?/runtimes/android/generator(.*)$ $proto://$host_and_port$1/core-concepts/android-runtime/binding-generator$2 permanent;
rewrite ^(/angular)?/runtimes/android/(.*) $proto://$host_and_port$1/core-concepts/android-runtime/$2 permanent;
rewrite ^/angular/runtimes/ios/how-to/Use-Native-Libraries$ $proto://$host_and_port/angular/plugins/Use-Native-iOS-Libraries permanent;
rewrite ^/runtimes/ios/how-to/Use-Native-Libraries$ $proto://$host_and_port/plugins/Use-Native-iOS-Libraries permanent;
rewrite ^(/angular)?/runtimes/ios/(.*) $proto://$host_and_port$1/core-concepts/ios-runtime/$2 permanent;
rewrite ^(/angular)?/runtimes/require$ $proto://$host_and_port$1/core-concepts/commonjs-modules permanent;
rewrite ^(/angular)?/core-concepts/project-structure$ $proto://$host_and_port$1/core-concepts/project-structure-app permanent;
# Redirect CLI docs under Tooling
rewrite ^(/angular)?/docs-cli/(.*) $proto://$host_and_port$1/tooling/docs-cli/$2 permanent;
rewrite ^(/angular)?/tooling/docs-cli/cloud/setup $proto://$host_and_port$1/tooling/docs-cli/cloud/cloud-setup permanent;
# Redirect the Cookbook under UI Widgets
rewrite ^/cookbook/ui/layouts/(.*) $proto://$host_and_port/ui/layouts/layout-containers permanent;
rewrite ^/cookbook/ui/(.*) $proto://$host_and_port/ui/ns-ui-widgets/$1 permanent;
# Redirect "Using Plugins" article
rewrite ^/plugins/plugins $proto://$host_and_port/core-concepts/plugins permanent;
rewrite ^/plugins/CocoaPods $proto://$host_and_port/plugins/cocoapods permanent;
# Redirect "How It Works" article
rewrite ^/start/how-it-works $proto://$host_and_port/core-concepts/technical-overview permanent;
# Redirect Chrome DevTools article
rewrite ^(/angular)?/tooling/chrome-devtools $proto://$host_and_port$1/tooling/debugging/chrome-devtools permanent;
rewrite ^(/angular)?/tooling/app-templates $proto://$host_and_port$1/app-and-screen-templates/app-templates permanent;
# Redirect Layout containers article
rewrite ^(/angular)?/ui/layout-containers$ $proto://$host_and_port$1/ui/layouts/layout-containers permanent;
rewrite ^(/angular)?/ui/layouts$ $proto://$host_and_port$1/ui/layouts/layouts permanent;
# Redirect common screens section && app-and-screen-templates
rewrite ^/angular/app-and-screen-templates/common-screens/(.*) $proto://$host_and_port/angular/ui/components permanent;
rewrite ^(/angular)?/app-and-screen-templates/app-templates $proto://$host_and_port$1/app-templates/app-templates permanent;
# Redirect publishing related articles
rewrite ^(/angular)?/publishing/android-abi-split $proto://$host_and_port$1/tooling/publishing/android-abi-split permanent;
rewrite ^(/angular)?/publishing/publishing-android-apps $proto://$host_and_port$1/tooling/publishing/publishing-android-apps permanent;
rewrite ^(/angular)?/publishing/publishing-ios-apps $proto://$host_and_port$1/tooling/publishing/publishing-ios-apps permanent;
rewrite ^(/angular)?/publishing/creating-launch-screens-ios $proto://$host_and_port$1/tooling/publishing/creating-launch-screens-ios permanent;
rewrite ^(/angular)?/publishing/creating-launch-screens-android $proto://$host_and_port$1/tooling/publishing/creating-launch-screens-android permanent;
# Redirect Code Sharing story to Angular flavour
rewrite ^/code-sharing/intro $proto://$host_and_port/angular/code-sharing/intro permanent;
# Redirect Lazy Loading article to Angular flavour
rewrite ^/performance-optimizations/lazy-loading $proto://$host_and_port/angular/performance-optimizations/lazy-loading permanent;
# Redirect Angular Navigation article to Angular flavour
rewrite ^/core-concepts/angular-navigation $proto://$host_and_port/angular/core-concepts/angular-navigation permanent;
# Redirect removed article to the Code Sharing intro
rewrite ^/angular/code-sharing/platform-specific-components $proto://$host_and_port/angular/code-sharing/intro permanent;
# Redirect base Angular link
rewrite ^/angular$ $proto://$host_and_port/angular/start/introduction permanent;
rewrite ^/angular/start/how-it-works$ $proto://$host_and_port/angular/core-concepts/technical-overview permanent;
rewrite ^/angular/start/troubleshooting$ $proto://$host_and_port/angular/troubleshooting permanent;
rewrite ^/angular/core-concepts/navigation$ $proto://$host_and_port/angular/core-concepts/angular-navigation permanent;
rewrite ^/start/troubleshooting$ $proto://$host_and_port/troubleshooting permanent;
# Redirect Angular Code Samples to UI Widgets
rewrite ^/angular/code-samples/ui/(.*) $proto://$host_and_port/angular/ui/ng-ui-widgets/$1 permanent;
rewrite ^/angular/code-samples/ui/layouts $proto://$host_and_port/angular/ui/layouts/layout-containers permanent;
rewrite ^/angular/code-samples/overview $proto://$host_and_port/angular/ui/ng-ui-widgets/action-bar permanent; # page doesn't exist, redirect to first UI widget
rewrite ^/angular/code-samples/modal-page $proto://$host_and_port/angular/ui/ng-ui-widgets/modal-page permanent;
rewrite ^/angular/ui/modal-view-ng $proto://$host_and_port/angular/ui/ng-components/modal-view-ng permanent;
rewrite ^/angular/ui/ng-ui-widgets/(.*) $proto://$host_and_port/angular/ui/ng-components/$1 permanent;
rewrite ^/angular/ui/ng-components/ng-ListView/(.*) $proto://$host_and_port/angular/ui/ng-components/RadListView/$1 permanent;
rewrite ^/angular/ui/professional-ui-components/(.*) $proto://$host_and_port/angular/ui/ng-components/$1 permanent;
rewrite ^/angular/ui/professional-ui-components/ng-ListView$ $proto://$host_and_port/angular/ui/ng-components/ng-RadListView permanent;
rewrite ^/angular/code-samples/camera $proto://$host_and_port/angular/ng-hardware-access/camera permanent;
rewrite ^/angular/code-samples/location $proto://$host_and_port/angular/ng-hardware-access/location permanent;
rewrite ^/angular/ng-hardware-access/camera https://github.com/NativeScript/nativescript-camera/blob/master/README.md permanent;
rewrite ^/angular/ng-hardware-access/location https://github.com/NativeScript/nativescript-geolocation/blob/master/README.md permanent;
rewrite ^/ui/list-view$ $proto://$host_and_port/angular/ui/ng-ui-widgets/listview permanent;
rewrite ^/listview$ $proto://$host_and_port/angular/ui/ng-ui-widgets/listview permanent;
rewrite ^(/angular)?/ui/rich-components$ $proto://$host_and_port$1/ui/professional-ui-components/overview permanent;
rewrite ^(/angular)?/ui/professional-ui-components/migration$ $proto://$host_and_port/5-4/$1/ui/professional-ui-components/migration;
rewrite ^(/angular)?/ui/professional-ui-components/getting-started$ $proto://$host_and_port$1/ui/overview permanent;
rewrite ^(/angular)?/ui/professional-ui-components/overview$ $proto://$host_and_port$1/ui/overview permanent;
rewrite ^/angular/ui/ng-components/overview$ $proto://$host_and_port/angular/ui/overview permanent;
# rewrite ^/angular/ui/(.*) $proto://$host_and_port/angular/ui/components/ permanent;
# Redirect Angular Code Samples (that were outside UI section)
rewrite ^/cookbook/formatted-string-ng $proto://$host_and_port/angular/ng-framework-modules/formatted-string permanent;
rewrite ^/angular/cookbook/formatted-string-ng $proto://$host_and_port/angular/ng-framework-modules/formatted-string permanent;
rewrite ^/angular/(cookbook|code-samples)/(application-settings|application|color|connectivity|file-system|fps-meter|http|platform|routing|timer|trace) $proto://$host_and_port/angular/ng-framework-modules/$2 permanent;
# Redirect the Cookbook under Framework Modules
rewrite ^/cookbook/(trace|application-settings|application|color|connectivity|console|fetch|file-system|formatted-string|formatted-string-ng|fps-meter|http|image-source|platform|timer|xml-parser) $proto://$host_and_port/ns-framework-modules/$1 permanent;
rewrite ^/cookbook/data/observable $proto://$host_and_port/ns-framework-modules/observable permanent;
rewrite ^/cookbook/data/observable-array $proto://$host_and_port/ns-framework-modules/observable-array permanent;
rewrite ^/cookbook/data/virtual-array $proto://$host_and_port/ns-framework-modules/virtual-array permanent;
rewrite ^/ui/components/overview$ $proto://$host_and_port/ui/overview permanent;
rewrite ^/ui/modal-view $proto://$host_and_port/ui/components/modal-view permanent;
rewrite ^/ui/ns-ui-widgets/(.*) $proto://$host_and_port/ui/components/$1 permanent;
rewrite ^/ui/components/ListView/(.*) $proto://$host_and_port/ui/components/RadListView/$1 permanent;
rewrite ^/ui/professional-ui-components/(.*) $proto://$host_and_port/ui/components/$1 permanent;
rewrite ^/ui/professional-ui-components/ListView$ $proto://$host_and_port/ui/components/RadListView permanent;
rewrite ^/hardware/camera https://github.com/NativeScript/nativescript-camera/blob/master/README.md permanent;
rewrite ^/hardware/location https://github.com/NativeScript/nativescript-geolocation/blob/master/README.md permanent;
# Redirect the Best Practices articles
rewrite ^(/angular)?/best-practices/(bundling-with-webpack|startup-times|images-optimisations) $proto://$host_and_port$1/performance-optimizations/$2 permanent;
rewrite ^(/angular)?/best-practices/(wire-backend|architecture-choice) $proto://$host_and_port$1/guides/$2 permanent;
rewrite ^(/angular)?/integration-with-existing-ios-and-android-apps/extend-existing-android-app $proto://$host_and_port$1/guides/integration-with-existing-ios-and-android-apps/extend-existing-android-app permanent;
rewrite ^(/angular)?/integration-with-existing-ios-and-android-apps/extend-existing-ios-app $proto://$host_and_port$1/guides/integration-with-existing-ios-and-android-apps/extend-existing-ios-app permanent;
rewrite ^/angular/best-practices/bundling-with-webpack $proto://$host_and_port/angular/performance-optimizations/bundling-with-webpack permanent;
# Redirect the Angular Groceries tutorial to proper "Get Started" subsections
rewrite ^/(angular|start)/tutorial/ng-chapter-\d$ $proto://$host_and_port/angular/start/introduction permanent;
rewrite ^/tutorial/ng-chapter-\d$ $proto://$host_and_port/start/introduction permanent;
rewrite ^(/angular)?/start/hello-world/ng-chapter-0 $proto://$host_and_port$1/start/introduction permanent;
rewrite ^(/angular)?/start/hello-world/ng-chapter-1 $proto://$host_and_port$1/start/introduction permanent;
# Redirect duplicate Icon Fonts aerticle to the updated UI examples
rewrite ^/ui/icon-fonts $proto://$host_and_port/ui/components/icon-fonts permanent;
rewrite ^/angular/ui/icon-fonts $proto://$host_and_port/angular/ui/ng-components/icon-fonts permanent;
rewrite ^(/angular)?/ui/ns-ui-widgets/icon-fonts $proto://$host_and_port$1/ui/icon-fonts permanent;
# Redirect the JavaScript Groceries tutorial links
rewrite ^/start/getting-started $proto://$host_and_port/start/introduction permanent;
rewrite ^/start/tutorial/chapter-\d$ $proto://$host_and_port/start/introduction permanent;
rewrite ^/tutorial/chapter-\d$ $proto://$host_and_port/start/introduction permanent;
# Redirect .html extension
rewrite ^/(.*)\.html$ $proto://$host_and_port/$1 permanent;
# Remove trailing slash
rewrite ^/(.*)/$ $proto://$host_and_port/$1 permanent;
location / {
try_files $uri $uri.html $uri/index.html @extensionless-html =404;
}
location @extensionless-html {
rewrite ^(.*)$ $1.html last;
}
}
}