-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathnginx.sample.conf
More file actions
101 lines (86 loc) · 2.51 KB
/
nginx.sample.conf
File metadata and controls
101 lines (86 loc) · 2.51 KB
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
# Sample nginx configuration file for phpBB.
# Tested with:
# - nginx 0.8.35
# - nginx 1.17.7 (mainline)
#
# Filename: /etc/nginx/sites-available/example.com.conf
#
# Replace example.com with your own domain name.
# Sample FastCGI server configuration.
# Filename: /etc/nginx/conf.d/php.conf
#
# upstream php {
# server unix:/run/php-fpm/php-fpm.sock;
# }
# Remove www domain prefix.
server {
listen 80;
# IPv6
listen [::]:80;
# Remove www
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
# Board configuration.
server {
listen 80;
# IPv6
listen [::]:80;
server_name example.com;
root /path/to/phpbb;
# phpBB uses index.htm
index index.php index.html index.htm;
# Loggers
error_log /var/log/nginx/example.com.error.log warn;
access_log /var/log/nginx/example.com.access.log;
location / {
try_files $uri $uri/ @rewriteapp;
# Pass the php scripts to FastCGI server specified in upstream declaration.
location ~ \.php(/|$) {
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
try_files $uri $uri/ /index.php$is_args$args;
fastcgi_pass php;
}
# Deny access to internal phpbb files.
location ~ /(config|common\.php|composer\.(json|lock)|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\w+)|store|vendor|vendor-ext) {
deny all;
# deny was ignored before 0.8.40 for connections over IPv6.
# Use internal directive to prohibit access on older versions.
internal;
}
}
location @rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}
# Correctly pass scripts for installer
location /install/ {
try_files $uri $uri/ @rewrite_installapp =404;
# Pass the php scripts to fastcgi server specified in upstream declaration.
location ~ \.php(/|$) {
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
try_files $uri $uri/ /install/index.php$is_args$args =404;
fastcgi_pass php;
}
}
location @rewrite_installapp {
rewrite ^(.*)$ /install/index.php/$1 last;
}
# Deny access to version control system directories.
location ~ /\.svn|/\.git {
deny all;
internal;
}
# Deny access to apache configuration files.
location ~ /\.htaccess|/\.htpasswd|/\.htgroups {
deny all;
internal;
}
}