-
-
Notifications
You must be signed in to change notification settings - Fork 256
/
nginx.conf
250 lines (208 loc) · 11.8 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
##
# phpMyFAQ nginx.conf file
#
# this assumes you installed in /
# if that is not the case,
# sed 's,/,,g' _nginx.conf
#
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.
#
# @author Florian Anderiasch <florian@phpmyfaq.de>
# @copyright 2011-2022 phpMyFAQ Team
# @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
# @link https://www.phpmyfaq.de
# @since 2011-01-14
#
server {
listen 80;
server_name example.org;
root /srv/www/default/public;
index index.php index.html index.htm;
rewrite // / break;
rewrite ^/$ /index.php last;
# Gzip Settings
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
gzip_comp_level 6;
gzip_vary on;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
location ~* \.(jpg|jpeg|gif|png|webp|svg|ico|mp4|webm|mpeg|ttf|otf|woff|woff2|css|js|pdf)$ {
expires 1y;
add_header Cache-Control "public";
}
# Additional configurations for specific file types
location ~* \.(svg|eot|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin "*";
}
# Specific cache-control for javascript files
location ~* \.(js)$ {
expires 1y;
add_header Cache-Control "public, max-age=31536000, immutable";
}
# Specific cache-control for CSS files
location ~* \.(css)$ {
expires 1y;
add_header Cache-Control "public, max-age=31536000, immutable";
}
# Rewrite logging, should be turned off on production
rewrite_log on
# X-Frame-Options to prevent clickjacking
add_header X-Frame-Options SAMEORIGIN;
location / {
index index.php;
if (!-f $request_filename) {
# show all categories
rewrite ^/showcat.html$ /index.php?action=show last;
# the search page
rewrite ^/search.html$ /index.php?action=search last;
# the opensearch page
rewrite ^/opensearch.xml$ /opensearch.php last;
# the add content page
rewrite ^/addcontent.html$ /index.php?action=add last;
# the ask question page
rewrite ^/ask.html$ /index.php?action=ask last;
# the open questions page
rewrite ^/open-questions.html$ /index.php?action=open-questions last;
# the help page
rewrite ^/help.html$ /index.php?action=help last;
# the contact page
rewrite ^/contact.html$ /index.php?action=contact last;
# the glossary page
rewrite ^/glossary.html$ /index.php?action=glossary last;
# the overview page
rewrite ^/overview.html$ /index.php?action=overview last;
# the login page
rewrite ^/login.html$ /index.php?action=login last;
# the privacy page
rewrite ^/privacy.html$ /index.php?action=privacy last;
# start page
rewrite ^/index.html$ /index.php last;
# sitemap (backward compatibility)
rewrite ^/sitemap-([a-zA-Z0-9]*)_([a-z\-]+).html$ /index.php?action=sitemap&letter=$1&lang=$2 last;
# a solution id page
rewrite ^/solution_id_([0-9]+).html$ /index.php?solution_id=$1 last;
# PMF faq record page
# * http://[...]/content/1/1/<LANGUAGE CODE>/<FAQ TOPIC>.htm
# * http://[...]/content/1/1/<LANGUAGE CODE>/<FAQ TOPIC>.html
rewrite content/([0-9]+)/([0-9]+)/([a-z\-]+)/(.+).html$ /index.php?action=faq&cat=$1&id=$2&artlang=$3 last;
# PMF category page with page count
# * http://[...]/category/1/<PAGE NUMBER/<CATEGORY NAME>.htm
# * http://[...]/category/1/<PAGE NUMBER/<CATEGORY NAME>.html
rewrite category/([0-9]+)/([0-9]+)/(.+).html$ /index.php?action=show&cat=$1&seite=$2 last;
# PMF category page
# * http://[...]/category/1/<CATEGORY NAME>.htm
# * http://[...]/category/1/<CATEGORY NAME>.html
rewrite category/([0-9]+)/(.+).html$ /index.php?action=show&cat=$1 last;
# PMF news page
rewrite news/([0-9]+)/([a-z\-]+)/(.+).html$ /index.php?action=news&newsid=$1&newslang=$2 last;
# PMF sitemap
# * http://[...]/sitemap/<LETTER>/<LANGUAGE CODE>.htm
# * http://[...]/sitemap/<LETTER>/<LANGUAGE CODE>.html
rewrite sitemap/([^\/]+)/([a-z\-]+).htm(l?)$ /index.php?action=sitemap&letter=$1&lang=$2 last;
# PMF Google sitemap
# * http://[...]/sitemap.xml
# * http://[...]/sitemap.gz
# * http://[...]/sitemap.xml.gz
rewrite sitemap.xml$ /sitemap.xml.php last;
rewrite sitemap.gz$ /sitemap.xml.php?gz=1 last;
rewrite sitemap.xml.gz$ /sitemap.xml.php?gz=1 last;
# PMF tags page with page count
# * http://[...]/tags/<ID>/<PAGE NUMBER>/<HEADER>.htm
rewrite tags/([0-9]+)/([0-9]+)/(.+).htm(l?)$ /index.php?action=search&tagging_id=$1&seite=$2 last;
# PMF tags page
# * http://[...]/tags/<ID>/<HEADER>.htm
rewrite tags/([0-9]+)/([^\/]+).htm(l?)$ /index.php?action=search&tagging_id=$1 last;
# REST API v2.0
# * http://[...]/api/v2.0/<ACTION>
rewrite api/v2.0/version /api.php?action=version last;
rewrite api/v2.0/language /api.php?action=language last;
rewrite api/v2.0/categories /api.php?action=categories last;
rewrite api/v2.0/searches/popular /api.php?action=searches&filter=popular last;
rewrite api/v2.0/search /api.php?action=search last;
rewrite api/v2.0/tags /api.php?action=tags last;
rewrite api/v2.0/open-questions /api.php?action=open-questions last;
rewrite api/v2.0/comments/([0-9]+) /api.php?action=comments&recordId=$1 last;
rewrite api/v2.0/attachments/([0-9]+) /api.php?action=attachments&recordId=$1 last;
rewrite api/v2.0/news /api.php?action=news last;
rewrite api/v2.0/login /api.php?action=login last;
rewrite api/v2.0/faqs/([0-9]+) /api.php?action=faqs&categoryId=$1 last;
rewrite api/v2.0/faqs/popular /api.php?action=faqs&filter=popular last;
rewrite api/v2.0/faqs/latest /api.php?action=faqs&filter=latest last;
rewrite api/v2.0/faqs/sticky /api.php?action=faqs&filter=sticky last;
rewrite api/v2.0/faqs/tags/([0-9]+) /api.php?action=faqs&tagId=$1 last;
rewrite api/v2.0/faqs /api.php?action=faqs last;
rewrite api/v2.0/faq/([0-9]+)/([0-9]+) /api.php?action=faq&categoryId=$1&recordId=$2 last;
# REST API v2.1
# * http://[...]/api/v2.1/<ACTION>
rewrite api/v2.1/version /api.php?action=version last;
rewrite api/v2.1/language /api.php?action=language last;
rewrite api/v2.1/categories /api.php?action=categories last;
rewrite api/v2.1/searches/popular /api.php?action=searches&filter=popular last;
rewrite api/v2.1/search /api.php?action=search last;
rewrite api/v2.1/tags /api.php?action=tags last;
rewrite api/v2.1/open-questions /api.php?action=open-questions last;
rewrite api/v2.1/comments/([0-9]+) /api.php?action=comments&recordId=$1 last;
rewrite api/v2.1/attachments/([0-9]+) /api.php?action=attachments&recordId=$1 last;
rewrite api/v2.1/news /api.php?action=news last;
rewrite api/v2.1/login /api.php?action=login last;
rewrite api/v2.1/faqs/([0-9]+) /api.php?action=faqs&categoryId=$1 last;
rewrite api/v2.1/faqs/popular /api.php?action=faqs&filter=popular last;
rewrite api/v2.1/faqs/latest /api.php?action=faqs&filter=latest last;
rewrite api/v2.1/faqs/sticky /api.php?action=faqs&filter=sticky last;
rewrite api/v2.1/faqs/tags/([0-9]+) /api.php?action=faqs&tagId=$1 last;
rewrite api/v2.1/faqs /api.php?action=faqs last;
rewrite api/v2.1/faq/([0-9]+)/([0-9]+) /api.php?action=faq&categoryId=$1&recordId=$2 last;
rewrite api/v2.1/faq /api.php?action=faq last;
rewrite api/v2.1/register /api.php?action=register last;
# REST API v2.2
# * http://[...]/api/v2.2/<ACTION>
rewrite api/v2.2/version /api.php?action=version last;
rewrite api/v2.2/language /api.php?action=language last;
rewrite api/v2.2/categories /api.php?action=categories last;
rewrite api/v2.2/category /api.php?action=category last;
rewrite api/v2.2/groups /api.php?action=groups last;
rewrite api/v2.2/searches/popular /api.php?action=searches&filter=popular last;
rewrite api/v2.2/search /api.php?action=search last;
rewrite api/v2.2/tags /api.php?action=tags last;
rewrite api/v2.2/open-questions /api.php?action=open-questions last;
rewrite api/v2.2/comments/([0-9]+) /api.php?action=comments&recordId=$1 last;
rewrite api/v2.2/attachments/([0-9]+) /api.php?action=attachments&recordId=$1 last;
rewrite api/v2.2/news /api.php?action=news last;
rewrite api/v2.2/login /api.php?action=login last;
rewrite api/v2.2/faqs/([0-9]+) /api.php?action=faqs&categoryId=$1 last;
rewrite api/v2.2/faqs/popular /api.php?action=faqs&filter=popular last;
rewrite api/v2.2/faqs/latest /api.php?action=faqs&filter=latest last;
rewrite api/v2.2/faqs/sticky /api.php?action=faqs&filter=sticky last;
rewrite api/v2.2/faqs/tags/([0-9]+) /api.php?action=faqs&tagId=$1 last;
rewrite api/v2.2/faqs /api.php?action=faqs last;
rewrite api/v2.2/faq/([0-9]+)/([0-9]+) /api.php?action=faq&categoryId=$1&recordId=$2 last;
rewrite api/v2.2/register /api.php?action=register last;
break;
}
}
try_files $uri @php;
location @php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include /etc/nginx/fastcgi_params;
}
location ~ '/.+\.ph(p|tml)(/|$)' {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 2d;
add_header Cache-Control "no-store";
}
}