Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Subscribe to RSS feed


Enable gzip compression on CapRover Docker server

Stanislav KhromovStanislav Khromov

I recently noticed that Google PageSpeed was complaining to me about “Enable text compression” for my CapRover applications.

To enable gzip compression in CapRover, it’s not enough to enable it on your application web server inside your Docker container, you also need to enable it in the global CapRover Nginx proxy server.

To do so, go to Settings > Base Config Location in nginx container

Go down to the line that says # gzip on;

Replace it with the following:

    gzip  on;
    gzip_types 
        text/plain
        text/css
        text/js
        text/xml
        text/html
        text/javascript
        application/javascript
        application/x-javascript
        application/json
        application/xml
        application/xml+rss
        application/rss+xml
        image/svg+xml/javascript;
    gzip_vary on;

Press Save and Update and wait for Nginx to reload.

Your config should now look like this:

Verify using curl (Replace example.org with your site URL):

curl -H "Accept-Encoding: gzip" https://example.org --output -

If you see garbled output in the console, it means gzip is now enabled!

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

Comments 0
There are currently no comments.