]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - nginx.conf.sample
Improved version of nginx sample config by XRevan86
[quix0rs-gnu-social.git] / nginx.conf.sample
1 server {
2     listen [::]:80;
3     listen 80;
4
5 # FIXME: change domain name here (and also make sure you do the same in the next 'server' section)
6     server_name social.example.org;
7
8 # redirect all traffic to HTTPS
9     rewrite ^ https://$host$request_uri? permanent;
10 }
11
12 server {
13 # HTTPS is mandatory on GNU social unless you are using Tor network. Seriously. Set it up with a cert (any cert) before you run the install.
14     listen [::]:443 ssl http2;
15     listen 443 ssl http2;
16
17 # Root
18 # Change the path below to where you installed
19 # GNU social
20     root /path/to/gnusocial/root;
21
22 # Server name
23 # Change "social.example.org" to your site's domain name
24 # GNU social MUST be installed in the domain root
25     server_name social.example.org;
26
27 # SSL
28 # Uncomment and change the paths to setup
29 # your SSL key/cert. See https://cipherli.st/
30 # for more information
31     ssl_certificate       ssl/certs/social.example.org.crt;
32     ssl_certificate_key   ssl/private/social.example.org.key;
33
34 # Logs
35 # Uncomment and change the paths to setup
36 # logging
37 #access_log /path/to/access.log;
38 #error_log  /path/to/error.log;
39
40 # Index
41     index index.php;
42
43 # PHP
44     location /index.php {
45         include fastcgi_params;
46         include snippets/fastcgi-php.conf;
47
48         fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
49         fastcgi_param SCRIPT_FILENAME $request_filename;
50
51         # Further optional configuration
52         #fastcgi_buffer_size 128K;
53         #fastcgi_buffers 4 256K;
54         #fastcgi_busy_buffers_size 256K;
55         #fastcgi_read_timeout 600s;
56         #fastcgi_send_timeout 300s;
57         #fastcgi_connect_timeout 75s;
58         #http2_push_preload on;
59     }
60
61 # Location
62     location / {
63         try_files $uri $uri/ @index_handler;
64     }
65
66 # Fancy URLs
67     error_page 404 @index_handler;
68     location @index_handler {
69         rewrite ^(.*)$ /index.php?p=$1 last;
70     }
71
72 # Restrict access that is unnecessary anyway
73     location ~ /\.(ht|git) {
74         deny all;
75     }
76
77 #
78 # Hardening (optional)
79 #
80 #    add_header Strict-Transport-Security "max-age=15768000; preload;";
81 #    add_header X-Content-Type-Options nosniff;
82 #    add_header Referrer-Policy strict-origin-when-cross-origin;
83 #    add_header Content-Security-Policy "default-src 'self' 'unsafe-inline'; frame-ancestors 'self'; form-action 'self'; style-src 'self' 'unsafe-inline'; img-src * blob: data:;";
84 #    add_header X-Permitted-Cross-Domain-Policies none;
85 #    add_header X-Robots-Tag all; # Not really hardening, just here for strictness purposes
86 #
87 #    client_max_body_size 15M;
88 #    client_body_buffer_size 128k;
89 #    gzip_vary on;
90 #
91 #    location ~* \.(?:css|js|woff|svg|gif|png|webp|ttf|ico|jpe?g)$ {
92 #        gzip on;
93 #        gzip_comp_level 4;
94 #        add_header Cache-Control "public";
95 #        expires 30d;
96 #        access_log off;
97 #        log_not_found off;
98 #    }
99 }