summaryrefslogtreecommitdiffstats
path: root/roles/pad-proxy/templates/etherpad.nginx.conf
blob: 3131178a36961071184e046d7b3d081de217fbe3 (plain) (blame)
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
# {{ ansible_managed }}

upstream etherpad_upstream {
	server 127.0.0.1:9001;
}

server {
  listen 80;
  server_name {{ etherpad_server_name }};
  {% if etherpad_tls %}
  include snippets/well-known-acme-challenge.conf;
  location / {
    return 302 https://$server_name$request_uri;
  }
}
server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name {{ etherpad_server_name }};
  include {{ etherpad_tls }};
  {% endif %}
  access_log  /var/log/nginx/{{ etherpad_server_name }}.access.log;
  location ~ ^/(locales/|locales.json|admin/|static/|pluginfw/|javascripts/|socket.io/|ep/|minified/|api/|ro/|error/|jserror/|favicon.ico|robots.txt) {
    proxy_buffering off;
    proxy_pass http://etherpad_upstream;
    }
  location /p/ {
    rewrite ^/p/(.*) /$1 redirect;
    }
  location /direct/ {
    rewrite /direct/(.*) /$1 break;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_pass http://etherpad_upstream/p/;
  }

  {% if use_wikimedia %} 
  location ~ ^/$ {
    return 302 https://etherpad.wikimedia.org/p/emacsconf-2022;
  }
  location / {
    rewrite /(.*) https://etherpad.wikimedia.org/p/emacsconf-$1 redirect;
  }
  {% else %}
  location ~ ^/pad-lister($|\/.*) {
    proxy_buffering off;
    proxy_pass http://etherpad_upstream;
  }
  location / {
    rewrite ^/?$ https://pad.emacsconf.org/2022 redirect;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_pass http://etherpad_upstream/p/;
    proxy_redirect / /p/;
    proxy_read_timeout  90;
    }
  {% endif %}
}