summarylogtreecommitdiffstats
path: root/filebin-nginx.conf
blob: 1fed639647eabfa59fd601d85967cc6e9f00bc8f (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
## Example config for http redirects
server {
	listen 80;
	listen [::]:80 default;
	server_name example.com;

	return 301 https://$server_name$request_uri;
}

## Example config for server secured with https
server {
	listen 0.0.0.0:443 ssl http2;
	listen [::]:443 ssl http2;
	server_name example.com;

	access_log /var/log/nginx/example.com/access.log combined if=$log_ip;
	error_log  /var/log/nginx/example.com/error.log;

	root /usr/share/webapps/filebin/public_html/;

	add_header X-Frame-Options DENY;

	location / {
		try_files $uri $uri/ @ee;
	}
	location @ee {
		rewrite ^(.*) /index.php?$1 last;
	}

	# Needs:
	# $config['download_driver'] = 'nginx';
	# $config['download_nginx_location'] = '/u';
	location ^~ /u/ {
		internal;
		gzip off;
		sendfile on;
		sendfile_max_chunk 100m;
		tcp_nopush on;
		tcp_nodelay on;
		keepalive_timeout 120;
		proxy_max_temp_file_size 0;
		chunked_transfer_encoding off;
		alias /usr/share/webapps/filebin/data/uploads/;
	}

	location ~ \.php$ {
		fastcgi_pass unix:/run/php-fpm/fb.sock;
		fastcgi_index index.php;
		include fastcgi.conf;
	}

	add_header Feature-Policy "geolocation 'none'; midi 'none'; notifications 'none'; push 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; vibrate 'none'; fullscreen 'none'; payment 'none'";

	add_header Content-Security-Policy "upgrade-insecure-requests; default-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'none'; font-src 'self'; object-src 'none'; media-src 'self'; worker-src 'none'; frame-src 'none'; form-action 'self'; frame-ancestors 'none'; base-uri 'self';";

	add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
	add_header Referrer-Policy "no-referrer, strict-origin-when-cross-origin";
	add_header X-Content-Type-Options nosniff;
	add_header X-XSS-Protection "1; mode=block";

	ssl_protocols TLSv1.2 TLSv1.3;

	# EECDH+AESGCM is a weaker cipher, but we need it for Android 5.0 / 6.0 support.
	ssl_ciphers "EECDH+AESGCM+SHA384:EECDH+AESGCM";
	#ssl_ciphers "EECDH+AESGCM+SHA384";

	ssl_prefer_server_ciphers on;
	ssl_ecdh_curve secp384r1;
	ssl_session_cache shared:SSL:10m;
	ssl_session_tickets off;
	ssl_stapling on;
	ssl_stapling_verify on;

	resolver 127.0.0.1 valid=300s;
	resolver_timeout 5s;

	# openssl dhparam -out /etc/ssl/dhparam.pem 4096
	ssl_dhparam /etc/ssl/dhparam.pem;

	# See https://wiki.archlinux.org/index.php/Certbot
	ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

	# Optional, needs to be generated
	#ssl_stapling_file /etc/letsencrypt/ocspresponse/fb.hash.works.der;
}

# vi:syntax=nginx