The Caddy example has `encode zstd gzip`; the nginx one had nothing, so a deployment following it shipped every asset uncompressed. Measured against the built app that is 915 KB on the wire where 307 KB would do -- the difference falls entirely on first load, and silently, since nothing about it is visible without inspecting response headers. `text/javascript` is listed explicitly. The server sends scripts with that type rather than `application/javascript`, so a conventional gzip_types list compresses the stylesheet and leaves the 647 KB script alone -- which is what happened on the first attempt at this change. text/event-stream is deliberately not listed. Compressing or buffering the push stream would break it; proxy_buffering is already off below for the same reason. Verified that /api/events still delivers a StateChange event through the proxy, as plain text, while assets come back gzipped with Vary set.
40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
# Example nginx location block for ihasmail behind TLS termination.
|
|
server {
|
|
listen 443 ssl http2;
|
|
server_name mail.example.com;
|
|
# ssl_certificate ...; ssl_certificate_key ...;
|
|
|
|
client_max_body_size 60m;
|
|
|
|
# ihasmail serves its bundle uncompressed and leaves this to the proxy, so
|
|
# without these directives the browser downloads about 915 KB where 307 KB
|
|
# would do. text/event-stream is deliberately absent from gzip_types: the
|
|
# push stream must not be compressed or buffered.
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 5;
|
|
gzip_min_length 1024;
|
|
# ihasmail serves scripts as text/javascript, so listing only
|
|
# application/javascript silently leaves the largest asset uncompressed.
|
|
gzip_types
|
|
application/javascript
|
|
application/json
|
|
application/manifest+json
|
|
image/svg+xml
|
|
text/css
|
|
text/javascript
|
|
text/plain;
|
|
|
|
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 $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
# Server-Sent Events (push notifications)
|
|
proxy_buffering off;
|
|
proxy_read_timeout 3600s;
|
|
}
|
|
}
|