mirror of
https://github.com/friendica/docker
synced 2024-09-28 13:06:34 +02:00
124 lines
3.8 KiB
Nginx Configuration File
124 lines
3.8 KiB
Nginx Configuration File
##
|
|
# Friendica Nginx configuration
|
|
# by Olaf Conradi, modified by Philipp Holzer
|
|
#
|
|
#worker_processes 4;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
error_log /var/log/nginx/error.log warn;
|
|
pid /var/run/nginx.pid;
|
|
|
|
http {
|
|
map $request_id $formatted_id {
|
|
"~*(?<p1>[0-9a-f]{8})(?<p2>[0-9a-f]{4})(?<p3>[0-9a-f]{4})(?<p4>[0-9a-f]{4})(?<p5>.*)$" "${p1}-${p2}-${p3}-${p4}-${p5}";
|
|
}
|
|
|
|
map $http_x_request_id $uuid {
|
|
default "${request_id}";
|
|
~* "${http_x_request_id}";
|
|
}
|
|
|
|
charset utf-8;
|
|
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
log_format logger-json escape=json '{"source": "nginx", "time": $msec, "resp_body_size": $body_bytes_sent, "host": "$http_host", "address": "$remote_addr", "request_length": $request_length, "method": "$request_method", "uri": "$request_uri", "status": $status, "user_agent": "$http_user_agent", "resp_time": $request_time, "upstream_addr": "$upstream_addr", "request_id": "$uuid"}';
|
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
access_log /var/log/nginx/access.log logger-json;
|
|
|
|
# If behind reverse proxy, forwards the correct IP
|
|
set_real_ip_from 10.0.0.0/8;
|
|
set_real_ip_from 172.16.0.0/12;
|
|
set_real_ip_from 192.168.0.0/16;
|
|
set_real_ip_from fc00::/7;
|
|
real_ip_header X-Real-IP;
|
|
|
|
upstream php-handler {
|
|
server app:9000;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
include /etc/nginx/conf.d/server_name.active;
|
|
|
|
index index.php;
|
|
|
|
root /var/www/html;
|
|
#Uncomment the following line to include a standard configuration file
|
|
#Note that the most specific rule wins and your standard configuration
|
|
#will therefore *add* to this file, but not override it.
|
|
#include standard.conf
|
|
# allow uploads up to 20MB in size
|
|
client_max_body_size 20m;
|
|
client_body_buffer_size 128k;
|
|
|
|
proxy_set_header X-Request-ID $uuid;
|
|
add_header X-Request-ID $uuid;
|
|
|
|
# rewrite to front controller as default rule
|
|
location / {
|
|
try_files $uri /index.php?pagename=$uri&$args;
|
|
}
|
|
|
|
# make sure webfinger and other well known services aren't blocked
|
|
# by denying dot files and rewrite request to the front controller
|
|
location ^~ /.well-known/ {
|
|
allow all;
|
|
try_files $uri /index.php?pagename=$uri&$args;
|
|
}
|
|
|
|
# statically serve these file types when possible
|
|
# otherwise fall back to front controller
|
|
# allow browser to cache them
|
|
# added .htm for advanced source code editor library
|
|
#location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {
|
|
# expires 30d;
|
|
# try_files $uri /index.php?pagename=$uri&$args;
|
|
#}
|
|
|
|
include mime.types;
|
|
|
|
# block these file types
|
|
location ~* \.(tpl|md|tgz|log|out)$ {
|
|
deny all;
|
|
}
|
|
|
|
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
|
# or a unix socket
|
|
location ~* \.php$ {
|
|
# Zero-day exploit defense.
|
|
# http://forum.nginx.org/read.php?2,88845,page=3
|
|
# Won't work properly (404 error) if the file is not stored on this
|
|
# server, which is entirely possible with php-fpm/php-fcgi.
|
|
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on
|
|
# another machine. And then cross your fingers that you won't get hacked.
|
|
try_files $uri =404;
|
|
|
|
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
|
|
fastcgi_pass php-handler;
|
|
|
|
fastcgi_read_timeout 300;
|
|
|
|
include fastcgi_params;
|
|
fastcgi_index index.php;
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
fastcgi_param HTTP_X_REQUEST_ID $uuid;
|
|
}
|
|
|
|
# deny access to all dot files
|
|
location ~ /\. {
|
|
deny all;
|
|
}
|
|
}
|
|
}
|