summaryrefslogtreecommitdiff
path: root/files/nginx_conf.j2
blob: 3c38ced33c20495d110fff36b5c3d76548036d2f (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
# SPDX-FileCopyrightText: 2024 Matthew Fennell <matthew@fennell.dev>
#
# SPDX-License-Identifier: AGPL-3.0-only

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

	ssl_certificate /etc/prosody/certs/{{ virtual_host }}.crt;
	ssl_certificate_key /etc/prosody/certs/{{ virtual_host }}.key;

	server_name {{ delegate_host }};

	location / {
		proxy_pass https://localhost:5281;
		proxy_set_header Host "{{ delegate_host }}";
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_buffering off;
		tcp_nodelay on;
	}
}

server {
	listen 80;
	listen [::]:80;

	server_name {{ delegate_host }};

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

{% if anonymous_login %}

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

	ssl_certificate /etc/prosody/certs/{{ virtual_host }}.crt;
	ssl_certificate_key /etc/prosody/certs/{{ virtual_host }}.key;

	server_name anon.{{ virtual_host }};

	location / {
		proxy_pass https://localhost:5281;
		proxy_set_header Host "anon.{{ virtual_host }}";
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_buffering off;
		tcp_nodelay on;
	}

	location /http-bind {
		proxy_pass https://localhost:5281;
		proxy_set_header Host "anon.{{ virtual_host }}";
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_buffering off;
		tcp_nodelay on;
	 }

	 location /.well-known/host-meta {
		add_header Access-Control-Allow-Origin * always;
		return 200 "<?xml version='1.0' encoding='utf-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
  <Link rel='urn:xmpp:alt-connections:xbosh'
        href='https://anon.{{ virtual_host }}/http-bind' />
</XRD>
";
	 }
}

server {
	listen 80;
	listen [::]:80;

	server_name anon.{{ virtual_host }};

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

{% endif %}