2 # Friendica Nginx configuration template to be autoconfigured with certbot
3 # based on sample-nginx.config by Olaf Conradi
5 # On Debian based distributions you can add this file to
6 # /etc/nginx/sites-available
8 # Then customize it to your needs. At least replace the server_name in line 41.
10 # Enable the configuration by
11 # symlink it to /etc/nginx/sites-enabled
14 # certbot --nginx -d friendica.example.net
16 # Then reload Nginx using
17 # systemctl nginx reload
22 # You should look at the following URL's in order to grasp a solid understanding
23 # of Nginx configuration files in order to fully unleash the power of Nginx.
25 # http://wiki.nginx.org/Pitfalls
26 # http://wiki.nginx.org/QuickStart
27 # http://wiki.nginx.org/Configuration
31 # This configuration assumes your domain is example.net
32 # You have a separate subdomain friendica.example.net
33 # You want all Friendica traffic to be https using letsencrypt with cerbot
34 # You have an SSL certificate and key for your subdomain
35 # You have PHP FastCGI Process Manager (php7.4-fpm) running on localhost
36 # You have Friendica installed in /var/www/friendica
41 server_name friendica.example.net;
43 # Point here to the path where your friendica files are located
44 root /var/www/friendica;
47 access_log /var/log/nginx/friendica_access.log;
48 # uncomment the following line if you would like to log errors in a separate file for friendica
49 #error_log /var/log/nginx/friendica_error.log;
54 # Uncomment the following line to include a standard configuration file Note
55 # that the most specific rule wins and your standard configuration will
56 # therefore *add* to this file, but not override it.
57 #include standard.conf
59 # allow uploads up to 20MB in size
60 client_max_body_size 20m;
61 client_body_buffer_size 128k;
63 # rewrite to front controller as default rule
65 try_files $uri /index.php?pagename=$uri&$args;
68 # make sure webfinger and other well known services aren't blocked
69 # by denying dot files and rewrite request to the front controller
70 location ^~ /.well-known/ {
72 rewrite ^ /index.php?pagename=$uri;
77 # statically serve these file types when possible otherwise fall back to
78 # front controller allow browser to cache them added .htm for advanced source
80 #location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {
82 # try_files $uri /index.php?pagename=$uri&$args;
85 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
88 # Zero-day exploit defense.
89 # http://forum.nginx.org/read.php?2,88845,page=3
90 # Won't work properly (404 error) if the file is not stored on this
91 # server, which is entirely possible with php-fpm/php-fcgi.
92 # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on
93 # another machine. And then cross your fingers that you won't get hacked.
96 # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
97 fastcgi_split_path_info ^(.+\.php)(/.+)$;
99 # With php5-cgi alone:
100 # fastcgi_pass 127.0.0.1:9000;
103 fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
105 include fastcgi_params;
106 fastcgi_index index.php;
107 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
109 fastcgi_buffers 16 16k;
110 fastcgi_buffer_size 32k;
113 # block these file types
114 location ~* \.(tpl|md|tgz|log|out)$ {
118 # deny access to all dot files
123 # deny access to the CLI scripts