-
Notifications
You must be signed in to change notification settings - Fork 2
/
nginx.conf.sigil
174 lines (154 loc) · 5.28 KB
/
nginx.conf.sigil
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
server {
listen [::]:80;
listen 80;
server_name api.cakephp.org api4.cakephp.org www.api.cakephp.org;
access_log /var/log/nginx/api.cakephp.org-access.log;
error_log /var/log/nginx/api.cakephp.org-error.log;
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
location / {
return 302 https://api.cakephp.org$request_uri;
}
}
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name api.cakephp.org;
access_log /var/log/nginx/api.cakephp.org-access.log;
error_log /var/log/nginx/api.cakephp.org-error.log;
index index.html index.htm;
ssl_certificate {{ $.APP_SSL_PATH }}/server.crt;
ssl_certificate_key {{ $.APP_SSL_PATH }}/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
set $cake3_latest "3.10";
set $cake4_latest "4.5";
set $cake5_latest "5.1";
set $authentication_latest "3.x";
set $authorization_latest "3.x";
set $chronos_latest "3.x";
set $elastic_search_latest "4.x";
set $queue_latest "2.x";
location ~ /\.ht {
deny all;
}
if ($http_user_agent ~ "HTTrack") {
return 499;
}
location ~ ^/(cache)?_?css/ {
gzip_vary on;
}
location ~ ^/(cache)?_?js/ {
gzip_vary on;
}
location ~ ^/img/ {
gzip_vary on;
}
location ~ ^/fonts/ {
gzip_vary on;
}
location ~ ^/$ {
rewrite ^ /${cake5_latest}/ permanent;
}
# Add trailing slashes.
location ~ ^/(\d+\.\d+)$ {
rewrite ^/(\d+\.\d+)$ /$1/ redirect;
}
location ~ ^/authentication/(\d\.x)$ {
rewrite ^/authentication/(\d\.x)$ /authentication/$1/ redirect;
}
location ~ ^/authorization/(\d\.x)$ {
rewrite ^/authorization/(\d\.x)$ /authorization/$1/ redirect;
}
location ~ ^/chronos/(\d\.\d+)$ {
rewrite ^/chronos/(\d\.\d+)$ /chronos/$1/ redirect;
}
location ~ ^/chronos/(\d\.x)$ {
rewrite ^/chronos/(\d\.x)$ /chronos/$1/ redirect;
}
location ~ ^/elastic-search/(\d\.x)$ {
rewrite ^/elastic-search/(\d\.x)$ /elastic-search/$1/ redirect;
}
location ~ ^/queue/(\d\.x)$ {
rewrite ^/queue/(\d\.x)$ /queue/$1/ redirect;
}
# Define latest aliases
location ~ ^/2\.(x|latest)/?(.*)$ {
return 303 https://api.cakephp.org/2.10/$2;
}
location ~ ^/3\.(x|latest)/?(.*)$ {
return 303 https://api.cakephp.org/${cake3_latest}/$2;
}
location ~ ^/4\.(x|latest)/?(.*)$ {
return 303 https://api.cakephp.org/${cake4_latest}/$2;
}
location ~ ^/5\.(x|latest)/?(.*)$ {
return 303 https://api.cakephp.org/${cake5_latest}/$2;
}
location ~ ^/authentication/?$ {
return 303 https://api.cakephp.org/authentication/${authentication_latest}/;
}
location ~ ^/authorization/?$ {
return 303 https://api.cakephp.org/authorization/${authorization_latest}/;
}
location ~ ^/chronos/?$ {
return 303 https://api.cakephp.org/chronos/${chronos_latest}/;
}
location ~ ^/elastic-search/?$ {
return 303 https://api.cakephp.org/elastic-search/${elastic_search_latest}/;
}
location ~ ^/queue/?$ {
return 303 https://api.cakephp.org/queue/${queue_latest}/;
}
# Forwarding for different versions
# This block has to be before the other 3.x versions so that 3.10 isn't
# matched as 3.1
location ~ ^/4.next/?(.*)$ {
proxy_set_header Host "api-4.cakephp.org";
proxy_pass http://localhost:80/cakephp/4.next/$1;
}
location ~ ^/(3\.\d+|4\.\d+|5\.\d+)/?(.*)$ {
proxy_set_header Host "api-4.cakephp.org";
proxy_pass http://localhost:80/cakephp/$1/$2;
}
location ~ ^/(1\.2|1\.3|2\.[0-9]+)/?(.*)$ {
proxy_set_header Host "api-3.cakephp.org";
proxy_pass http://localhost:80/$1/$2;
}
location ~ ^/resources/(.*)$ {
proxy_set_header Host "api-3.cakephp.org";
proxy_pass http://localhost:80/resources/$1;
}
# authentication & authorization
location ~ ^/authentication/([23]\.x)/?(.*)$ {
proxy_set_header Host "api-4.cakephp.org";
proxy_pass http://localhost:80/authentication/$1/$2;
}
location ~ ^/authorization/([23]\.x)/?(.*)$ {
proxy_set_header Host "api-4.cakephp.org";
proxy_pass http://localhost:80/authorization/$1/$2;
}
# Chronos API docs 1.x compatibility handling
location ~ ^/chronos/(1\.0|1\.1|1\.2|1\.3)/?(.*)$ {
proxy_set_header Host "api-4.cakephp.org";
proxy_pass http://localhost:80/chronos/1.x/$2;
}
# Chronos API docs 1.x and 2.x versions
location ~ ^/chronos/([123]\.x)/?(.*)$ {
proxy_set_header Host "api-4.cakephp.org";
proxy_pass http://localhost:80/chronos/$1/$2;
}
# elastic-search API docs 2.x, 3.x versions
location ~ ^/elastic-search/([234]\.x)/?(.*)$ {
proxy_set_header Host "api-4.cakephp.org";
proxy_pass http://localhost:80/elastic-search/$1/$2;
}
# queue
location ~ ^/queue/([12]\.x)/?(.*)$ {
proxy_set_header Host "api-4.cakephp.org";
proxy_pass http://localhost:80/queue/$1/$2;
}
# Favicon
location ~ ^/favicon.png {
rewrite ^ /4.0/favicon.png permanent;
}
}