]> git.mxchange.org Git - friendica.git/blob - mods/sample-nginx-certbot.config
Merge pull request #12246 from MrPetovan/bug/notices
[friendica.git] / mods / sample-nginx-certbot.config
1 ##
2 # Friendica Nginx configuration template to be autoconfigured with certbot
3 # based on sample-nginx.config by Olaf Conradi
4 #
5 # On Debian based distributions you can add this file to
6 # /etc/nginx/sites-available
7 #
8 # Then customize it to your needs. At least replace the server_name in line 41.
9 #
10 # Enable the configuration by
11 # symlink it to /etc/nginx/sites-enabled
12 #
13 # and run
14 # certbot --nginx -d friendica.example.net
15 #
16 # Then reload Nginx using
17 # systemctl nginx reload
18 #
19 ##
20
21 ##
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.
24 #
25 # http://wiki.nginx.org/Pitfalls
26 # http://wiki.nginx.org/QuickStart
27 # http://wiki.nginx.org/Configuration
28 ##
29
30 ##
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
37 ##
38
39 server {
40   listen 80;
41   server_name friendica.example.net;
42
43   # Point here to the path where your friendica files are located
44   root /var/www/friendica;
45
46   # Logging
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;
50
51   index index.php;
52   charset utf-8;
53
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
58
59   # allow uploads up to 20MB in size
60   client_max_body_size 20m;
61   client_body_buffer_size 128k;
62
63   # rewrite to front controller as default rule
64   location / {
65     try_files $uri /index.php?pagename=$uri&$args;
66   }
67
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/ {
71     allow all;
72     rewrite ^ /index.php?pagename=$uri;
73   }
74
75   include mime.types;
76
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
79   # code editor library
80   #location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {
81   #  expires 30d;
82   #  try_files $uri /index.php?pagename=$uri&$args;
83   #}
84
85   # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
86   # or a unix socket
87   location ~* \.php$ {
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.
94     try_files $uri =404;
95
96     # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
97     fastcgi_split_path_info ^(.+\.php)(/.+)$;
98
99     # With php5-cgi alone:
100     # fastcgi_pass 127.0.0.1:9000;
101
102     # With php7.4-fpm:
103     fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
104
105     include fastcgi_params;
106     fastcgi_index index.php;
107     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
108
109     fastcgi_buffers 16 16k;
110     fastcgi_buffer_size 32k;
111   }
112
113   # block these file types
114   location ~* \.(tpl|md|tgz|log|out)$ {
115     deny all;
116   }
117
118   # deny access to all dot files
119   location ~ /\. {
120     deny all;
121    }
122
123    # deny access to the CLI scripts
124   location ^~ /bin {
125     deny all;
126   }
127 }
128