]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/tips/nginx.mdwn
(no commit message)
[git.ikiwiki.info.git] / doc / tips / nginx.mdwn
1 There's a lot of scattered info about nginx. This is what I've deduced from reading various blogs, Debian READMEs and the [nginx wiki](https://www.nginx.com/resources/wiki/start/topics/examples/fcgiwrap/).
3 For Debian I suggest installing nginx from [dotdeb](https://www.dotdeb.org/instructions/). They provide the latest stable versions.
5 For cgi install ```fcgiwrap```
7 Here is a full sites-enabled/example.com configure for hosting ikiwiki on the root domain, example.com:
9 ```
10 server {
11         listen 443 default_server;
12         listen [::]:443 ssl default_server;
13         root /home/ikiwiki/public_html/wiki;
15         index index.html;
17         server_name example.com www.example.com;
19         ssl_certificate /etc/nginx/ssl/example.com.pem;
20         ssl_certificate_key /etc/nginx/ssl/example.com.key;
21         
22         ssl_session_timeout 5m;
23         ssl_session_cache shared:SSL:50m;
24         ssl_dhparam /etc/nginx/ssl/dhparam.pem;
25         ssl_prefer_server_ciphers on;
26         ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
27         ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
28         resolver 8.8.8.8;
29         ssl_stapling on;
30         ssl_trusted_certificate /etc/nginx/ssl/example.com.pem;
31         add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
33         client_max_body_size 10m;
35         # ikiwiki site
37         location / {
38                 try_files $uri $uri/ =404;
39         }
41         location ~ .cgi {
42                 gzip off;
43                 fastcgi_pass unix:/var/run/fcgiwrap.socket;
44                 include /etc/nginx/fastcgi_params;
46         }
47 }
50 ##
51 #Forward http to https
52 ##
54 server {
55         listen 80 default_server;
56         listen [::]:80 default_server;
57         server_name example.com www.example.com;
58         return 301 https://$host$request_uri;
59 }
60 ```
62 For SSL tips this [gist](https://gist.github.com/plentz/6737338) is a good source of information. Use [letsencrypt](https://letsencrypt.org/) to get free certificates.