summaryrefslogtreecommitdiff
path: root/config-parabola-mgmt-nginx.PKGBUILD
blob: d1bf9982883c47192e0e26231248ad61d96c89f4 (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
. ${BUILDFILE%/*}/common.sh
pkgver=20180826

package() {
preamble
# #### Nginx

depends+=(nginx)

# `fastcgi.conf`, `fastcgi_params`, `scgi_params` and `uwsgi_params`
# have been edited to pass 127.0.0.1 as the client IP address to
# worker processes, to protect user privacy.
add-file -m755 usr/share/holo/files/10-"$pkgname"/etc/nginx/fastcgi.conf.holoscript <<'EOF'
#!/bin/sh
{
	echo '# -*- Mode: nginx; nginx-indent-level: 8; indent-tabs-mode: t -*-'
	echo
	sed 's/\$remote_addr;$/127.0.0.1; # $remote_addr; # Anonymize/'
} | awk '/^$/{ s=1 } /./&&!x[$0]++{ if(s){print ""} print; s=0 }'
EOF
ln -sfT fastcgi.conf.holoscript usr/share/holo/files/10-"$pkgname"/etc/nginx/fastcgi_params.holoscript
ln -sfT fastcgi.conf.holoscript usr/share/holo/files/10-"$pkgname"/etc/nginx/scgi_params.holoscript
ln -sfT fastcgi.conf.holoscript usr/share/holo/files/10-"$pkgname"/etc/nginx/uwsgi_params.holoscript

add-file etc/nginx/sites/alias-parabolagnulinux_org.conf <<EOF
# -*- Mode: nginx; nginx-indent-level: 8; indent-tabs-mode: t -*-
# Redirect everything from *.parabolagnulinux.org to *.parabola.nu

# Top-level domain
server {
	server_name parabolagnulinux.org;
	listen 443 ssl http2;
	listen [::]:443 ssl http2;

	location / { return 301 https://www.parabola.nu\$request_uri; }
}

# Wildcard sub-domain
server {
	server_name ~^(?<subdomain>[^\\.]*)\\.parabolagnulinux\\.org\$;
	listen 443 ssl http2;
	listen [::]:443 ssl http2;

	location / { return 301 https://\$subdomain.parabola.nu\$request_uri; }
}
EOF

add-file etc/nginx/sites/meta-unknown-domain.conf <<EOF
# -*- Mode: nginx; nginx-indent-level: 8; indent-tabs-mode: t -*-

server {
	listen 443 ssl http2 default_server;
	listen [::]:443 ssl http2 default_server;

	return 301 https://www.parabola.nu/404;
}
EOF

add-unit etc/systemd/system/multi-user.target.wants/nginx.service

postamble
}