-
-
Notifications
You must be signed in to change notification settings - Fork 256
/
nginx.conf
165 lines (129 loc) · 6.19 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
##
# 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) {
# General pages
rewrite ^/add-faq.html$ /index.php?action=add last;
rewrite ^/add-question.html$ /index.php?action=ask last;
rewrite ^/show-categories.html$ /index.php?action=show last;
rewrite ^/(search|open-questions|help|contact|glossary|overview|login|privacy|index).html$ /index.php?action=$1 last;
rewrite ^/(login) /index.php?action=login last;
# a solution id page
rewrite ^/solution_id_([0-9]+).html$ /index.php?solution_id=$1 last;
# the bookmarks page
rewrite ^/bookmarks.html$ /index.php?action=bookmarks last;
# PMF faq record page
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
rewrite category/([0-9]+)/([0-9]+)/(.+).html$ /index.php?action=show&cat=$1&seite=$2 last;
# PMF category page
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
rewrite sitemap/([^\/]+)/([a-z\-]+).htm(l?)$ /index.php?action=sitemap&letter=$1&lang=$2 last;
# PMF Google sitemap
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;
# robots.txt
rewrite robots.txt$ /robots.txt.php last;
# PMF tags page with page count
rewrite tags/([0-9]+)/([0-9]+)/(.+).htm(l?)$ /index.php?action=search&tagging_id=$1&seite=$2 last;
# PMF tags page
rewrite tags/([0-9]+)/([^\/]+).htm(l?)$ /index.php?action=search&tagging_id=$1 last;
# Authentication services
rewrite services/webauthn(.*) /services/webauthn/index.php last;
# User pages
rewrite user/(ucp|bookmarks|request-removal|logout|register) /index.php?action=$1 last;
# Private APIs
rewrite api/(autocomplete|bookmark/([0-9]+)|user/data/update|user/password/update|user/request-removal|contact|voting|register|captcha|share|comment/create|faq/create|question/create|webauthn/prepare|webauthn/register|webauthn/prepare-login|webauthn/login) /api/index.php last;
# Setup and update pages
rewrite setup/ /setup/index.php last;
rewrite update/ /update/index.php last;
# Setup APIs
rewrite api/setup/(check|backup|update-database) /api/index.php last;
# Administration API
rewrite admin/api/(.*) /admin/api/index.php last;
# Administration pages
rewrite admin/(attachments|backup|configuration|elasticsearch|export|group|import|instance|instances|password|session-keep-alive|stopwords|system|update|user) /admin/front.php last;
# REST API v3.0 and v3.1
rewrite ^api/v3\.[01]/(.*) /api/index.php 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";
}
}