# Written by the inbuxa installer {{.Version}} for {{.Domain}}. # # For the web server already on this machine: nginx. Include it from # /etc/nginx/conf.d/ (or sites-enabled/), set each ssl_certificate pair to the # certificate you have for those names, check it with `nginx -t`, and reload. # The installer loads nothing and restarts nothing; this is yours to adjust. # # Everything is passed to loopback, where the installer put each program: # 127.0.0.1:8081 the mail server's web side (JMAP, CalDAV, CardDAV, # autoconfig, MTA-STS) # 127.0.0.1:8082 the console # 127.0.0.1:8080 the webmail # # The mail server trusts X-Forwarded-For from here, so every block sets it to # the client's own address rather than passing on what the client sent. {{- if .ServesServer}} # Port 80 for the server's names: its own certificate challenges, which it # answers itself once certificates are turned on in the console, and a # redirect for everything else. server { listen 80; listen [::]:80; server_name {{join .ServerNames " "}}; location /.well-known/acme-challenge/ { proxy_pass http://127.0.0.1:8081; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } location / { return 308 https://$host$request_uri; } } # The mail server's web side. Push arrives as a long-lived stream, so it is # not buffered and not timed out early. server { listen 443 ssl; listen [::]:443 ssl; http2 on; server_name {{join .ServerNames " "}}; ssl_certificate /etc/ssl/inbuxa/{{.MailHost}}.fullchain.pem; ssl_certificate_key /etc/ssl/inbuxa/{{.MailHost}}.key.pem; client_max_body_size 100m; location / { proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_buffering off; proxy_read_timeout 1h; } } {{- end}} {{- if or .Console .ConsoleFiles}} # The console: static files. It talks to the mail server from the browser, # so nothing here proxies the API. server { listen 80; listen [::]:80; server_name {{.ConsoleHost}}; return 308 https://$host$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; http2 on; server_name {{.ConsoleHost}}; ssl_certificate /etc/ssl/inbuxa/{{.ConsoleHost}}.fullchain.pem; ssl_certificate_key /etc/ssl/inbuxa/{{.ConsoleHost}}.key.pem; {{- if .ConsoleFiles}} # Installed on this machine as files: served from them. Any path that # is not a file is the app's own route; hashed assets are cached for a # year, and index.html, which names them, never. root {{.ConsoleFiles}}; location / { try_files $uri $uri/ /index.html; } location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; } location = /index.html { add_header Cache-Control "no-cache"; } {{- else}} location / { proxy_pass http://127.0.0.1:8082; proxy_set_header Host $host; } {{- end}} } {{- end}} {{- if .ServesWebmail}} # The webmail. Push arrives as Server-Sent Events: flushed as written, and # held open. server { listen 80; listen [::]:80; server_name {{.WebmailHost}}; return 308 https://$host$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; http2 on; server_name {{.WebmailHost}}; ssl_certificate /etc/ssl/inbuxa/{{.WebmailHost}}.fullchain.pem; ssl_certificate_key /etc/ssl/inbuxa/{{.WebmailHost}}.key.pem; client_max_body_size 100m; location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_buffering off; proxy_read_timeout 1h; } } {{- end}}