1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-28 11:32:57 +01:00
php-phpbb/phpBB/docs/nginx.sample.conf
Alfredo Ramos 5d5f34518d [ticket/16313] Remove http block from sample Nginx configuration file
Change placeholder domain to example.com

Also prefer fastcgi.conf over fastcgi_params as per Nginx documentation.

PHPBB3-16313
2020-01-09 19:10:25 -06:00

104 lines
2.6 KiB
Plaintext

# 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.
# If you want to use the X-Accel-Redirect feature,
# add the following to your config.php.
#
# define('PHPBB_ENABLE_X_ACCEL_REDIRECT', true);
#
# See http://wiki.nginx.org/XSendfile for the details
# on X-Accel-Redirect.
# 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/ /app.php$is_args$args;
fastcgi_pass php;
}
# Deny access to internal phpbb files.
location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\w+)|store|vendor) {
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 ^(.*)$ /app.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/app.php$is_args$args =404;
fastcgi_pass php;
}
}
location @rewrite_installapp {
rewrite ^(.*)$ /install/app.php/$1 last;
}
# Deny access to version control system directories.
location ~ /\.svn|/\.git {
deny all;
internal;
}
}