Question

(Nginx + Ghost 1-Click) How can I add gzip headers to specific content types?

Posted May 2, 2020 56 views
NginxGhost

Hi all,

I have embedded a Unity WebGL build into a custom page template on my website. This works as intended. However the load time is a little slow because the files being served are gzipped despite the server not sending this header information. You can see the recommendations from the Unity documentation here.

I’ve attempted to add the following behind my .well-known location block in /etc/nginx/sites-enabled/my.domain.conf and restarting nginx but it seems to have no effect.

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

server_name my.domain;
root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_pass http://127.0.0.1:2368;

}

location ~ /.well-known {
    allow all;
}

location ~ .+\.unityweb$ {
    add_header Content-Encoding gzip;
}

client_max_body_size 50m;
}

Is there anything else I need to do specifically for Ghost CMS to make this change work? I’m also not overly familiar with nginx so is this location correct? I have been using this forum thread to get the Content Encoding syntax.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

I’m taking my firs steps in building a nginx server that can transcode my RTMP stream using ffmpeg and forward them to my server. I’ve gobbled together a config file that should be able to do this, but i’m im not getting any input from the ffmpeg streams yet. Could someone point me in the right direction as to where to look for the solution? I’ve gone through a bunch of tutorials and arcicles but couldnt find anything working for me just yet.

Submit an Answer