aboutsummaryrefslogtreecommitdiff
path: root/doc/tips/nginx.mdwn
blob: 6e6a409b1a6130388a7d8d8d96aa9a211283f108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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/).

For Debian I suggest installing nginx from [dotdeb](https://www.dotdeb.org/instructions/). They provide the latest stable versions.

For cgi install ```fcgiwrap```

Here is a full sites-enabled/example.com configure for hosting ikiwiki on the root domain, example.com:

```
server {
	listen 443 default_server;
        listen [::]:443 ssl default_server;
	root /home/ikiwiki/public_html/wiki;

	index index.html;

	server_name example.com www.example.com;

	ssl_certificate /etc/nginx/ssl/example.com.pem;
	ssl_certificate_key /etc/nginx/ssl/example.com.key;
	
	ssl_session_timeout 5m;
	ssl_session_cache shared:SSL:50m;
	ssl_dhparam /etc/nginx/ssl/dhparam.pem;
	ssl_prefer_server_ciphers on;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
	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";
  	resolver 8.8.8.8;
  	ssl_stapling on;
  	ssl_trusted_certificate /etc/nginx/ssl/example.com.pem;
	add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";

        client_max_body_size 10m;

        # ikiwiki site

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ .cgi {
                gzip off;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                include /etc/nginx/fastcgi_params;

        }
}


##
#Forward http to https
##

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name example.com www.example.com;
        return 301 https://$host$request_uri;
}
```

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.