/
nginx.conf
120 lines (93 loc) · 4.44 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
##
# 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;
# 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;
# 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;
# 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) /api/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;
# REST API v3.0
rewrite api/v3.0/(.*) /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";
}
}