Using Brotli Compression in NGINX

Using Brotli Compression in NGINX

PERFORMANCE

Brotli is gaining steam as the compression algorithm du jour for high performance websites. Created back in 2013 by Google to decrease the size of WOFF files, Brotli was standardized in 2016 as part of RFC 7932. The sales pitch for Brotli is better compression than Gzip – with similar CPU usage. Better compression leads to faster performance, but how much better is it?

Using Brotli in NGINX

To find out, we need to enable Brotli compression. Gzip has been available in NGINX for some time. It’s a bit fiddly to ensure you’re compressing all the appropriate mime types, but mostly it’s easy to setup and get going.

Unfortunately, Brotli is not part of the default NGINX package at this time, so you have to load it as a dynamic or static module. The Brotli NGINX module is currently developed and maintained by the folks at Google.

The Easy (but Expensive) Way

NGINX Plus has official support for the Brotli module. They’ve done all the hard work of packaging the module in to the NGINX Plus repository for you. It’s just an apt-get install away! That is – if you’re a paying customer.

The Hard Way

Since we’re cheap, we don’t have access to the NGINX Plus repository. We only have the open source version of NGINX, which means we need to load the module by hand. The process is roughly this:

  • Install a load of pre-reqs
  • Compile the module for your system (groan)
  • Configure NGINX to use the newly compiled module

Installing Dependencies

Even though you’ve likely installed NGINX via some kind of package manager (apt, yum, whatever) you’re still going to need the source for the version you’ve installed. Even worse, you’re going to need all the dependencies that the source was originally compiled against. From the horse’s mouth:

Dynamic modules must be compiled against the same version of NGINX they are loaded into.

And from the Google Brotli module installation docs:

You will need to use exactly the same ./configure arguments as your Nginx configuration and append –with-compat –add-dynamic-module=/path/to/ngx_brotli to the end, otherwise you will get a “module is not binary compatible” error on startup. You can run nginx -V to get the configuration arguments for your Nginx installation.

So that all sounds complicated and terrible, but fortunately it’s not too bad if you are OK with some blind faith and a little copy/pasting. In all the following examples, we’re using Ubuntu 20.04.

Installing all the Pre-Reqs

apt-get install build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev \
libssl-dev libgd-dev libxml2 libxml2-dev uuid-dev libxslt-dev

Once you’ve got those, you’re going to need the NGINX source and the Brotli module source.

nginx -v
# nginx version: nginx/1.18.0 (Ubuntu)

Ok, so we need 1.18.0 since that’s what’s installed on our system. We also need to clone the Brotli module from Github. There are Git submodules in play, so make sure when you clone the Brotli module repository you use the --recursive flag!

wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -xzvf nginx-1.18.0.tar.gz

# Ensure you use the --recursive flag
git clone https://github.com/google/ngx_brotli.git --recursive

Getting the Configuration Arguments Right

So remember all that talk about binary compatability? When NGINX was originally compiled for your system, it was compiled with a whole slew of configure arguments. When we compile the module, we need to make sure they are exactly the same, plus we need to add a few more! To see the original configure arguments we can use the -V flag (note the capital letter this time)

All the configure arguments.
All the configure arguments.

Copy that huge list of configure arguments and paste it somewhere for safekeeping. Now comes the fun part.

Compile Time, Baby

cd nginx-1.18.0
# Paste in the configure arguments and then add the second line
# If your system is different, ./configure may spit out
# additional dependencies you need to install
./configure [ALL THE CONFIGURE ARGUMENTS] \
--with-compat --add-dynamic-module=../ngx_brotli

# If ./configure finishes successfully, you can make the module!
make modules

The compiled modules will be emitted to the obj/ folder within the source directory once compilation is successful. We need to move the .so files to a place NGINX can find them.

cp objs/ngx_http_brotli_filter_module.so /usr/lib/nginx/modules
cp objs/ngx_http_brotli_static_module.so /usr/lib/nginx/modules

Huzzah! Now we’re ready to configure NGINX. Having fun yet?

Configuring NGINX

This is the easy part. In nginx.conf you need to load the module. This needs to be the very first thing in the file.

# for compressing responses on-the-fly
load_module modules/ngx_http_brotli_filter_module.so;
# for serving pre-compressed files
load_module modules/ngx_http_brotli_static_module.so;

And then we need to turn it on! You can enable Brotli in specific location blocks, or at the server level.

Brotli Settings

    brotli on;
brotli_comp_level 6;
    brotli_types application/javascript application/x-javascript application/xml application/xml+rss 
    application/json text/javascript image/x-icon image/vnd.microsoft.icon image/bmp image/svg+xml text/xml text/css text/plain;

And finally, we need to test our configuration to make sure we did everything right, and then reload NGINX

systemctl restart nginx.service

Step 6 – Verify Brotli Module

At this point, The Nginx will be successfully installed and configured with Brotli support. You can verify whether the Brotli module is enabled or not by running the command:

curl -H 'Accept-Encoding: br' -I http://localhost

You will get the “Content-Encoding: br” in the output:

HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Sat, 31 Oct 2020 06:30:24 GMT
Content-Type: text/html
Last-Modified: Tue, 21 Apr 2020 14:09:01 GMT
Connection: keep-alive
ETag: W/"5e9efe7d-264"
Content-Encoding: br

3 thoughts on “Using Brotli Compression in NGINX

  1. When testosterone ranges are low, this is typically when we see low libido,
    fatigue, and even depression. And when they’re
    excessive, as we frequently see in polycystic ovarian syndrome (PCOS), ladies experience acne, irregular
    periods, and hair development on the chin, chest and stomach.

    For lots of girls, it will imply they should
    test for progesterone between days of their cycle.
    Once More, this advice may change if you’re not ovulating day
    14 of your cycle — which is definitely fairly common,
    or if your typical cycle is shorter or longer than 28 days.

    A sperm count could present more information in case a person is apprehensive about having sure symptoms surfacing.
    Lumps, cysts, and different abnormalities in reproductive organs may help your physician diagnose
    issues which are impacting your hormone steadiness, as nicely as
    posing a danger on your overall health status. There are quite a few forms of tests on your
    physician to select from in order to detect
    a hormonal imbalance. So, you do anabolic steroids work – http://www.cbl.Health – want to completely
    confide in your physician about your signs and symptoms for him to order the best hormones to be examined.
    Under are some frequent AMH lab values used by LabCorp to determine appropriate
    ranges of AMH based mostly on a woman’s age.
    If you have missed your period or have stopped menstruating,
    the first test your healthcare supplier will likely do
    is a being pregnant take a look at. All The
    Time converse with your healthcare provider to understand
    what remedy choices can be found.
    If you suspect that you’re experiencing a hormonal imbalance or the negative effects of
    age-related hormone fluctuation, it’s a good idea to
    begin recording your signs each day. This document could be an essential tool when you communicate to a hormone specialist and begin the journey
    of diagnosis and therapy. Though noticeable symptoms are not
    the entire picture, it’s a good place to start out and can help you
    to better perceive your well being targets.
    Follicle-stimulating hormone (FSH) and luteinizing hormone (LH) are
    made by the pituitary gland, a pea-sized organ located at
    the base of your brain. FSH stimulates the expansion of an egg follicle within the ovary,
    whereas the surge of LH triggers the discharge of the egg during ovulation.
    Like versions that use a urine sample, a being pregnant blood take a look at appears for human chorionic gonadotropin (hCG), a hormone that is solely present
    in case you are pregnant.
    E2 ranges decline modestly through the ovulatory phase and
    then increase once more gradually until the midpoint of the luteal phase and ultimately decline back to early follicular levels.
    An estrogen test is used to measure the levels of estrogens in a person’s body.
    Estrogens are hormones that play a crucial role in the feminine reproductive system and are additionally present in smaller
    amounts in males. Testing estrogen levels might help determine the danger of
    sure health conditions and the effectiveness of hormone remedy.

    During the first 2 to 5 years following menopause or
    ovarian failure, blood levels of estradiol drop to a mean vary of about 25 to 35 pg/ml.
    That’s why InsideTracker recommends monitoring this
    hormone and working with a healthcare provider for support.
    The insights are based on organic intercourse, so should you
    use gender-affirming hormone therapy, choose the choice that
    aligns with it.
    Before you go to your doctor, track any signs you’re experiencing, how often they happen,
    and the way severe they’re. Note whenever you had your
    last period and report any irregularities in timing that might
    have occurred. Make a list of medications and dietary supplements you’re currently taking.
    You could go months without a interval through
    the perimenopause section. Nonetheless, when you miss a interval and aren’t utilizing contraception, see your physician or take
    a test to just be sure you aren’t pregnant.
    Menopause usually begins between the ages of forty and 60, though it’s most typical for
    it to begin out round age 51. It’s more doubtless to have begun if you haven’t had a interval in over
    six months.
    As men age, testosterone converts to estrogen, generally causing a hormonal imbalance.
    A female hormone test is a blood check that measures ranges
    of a woman’s sex hormones, including estrogen and progesterone.
    Female hormone exams can also be used within the prognosis of hormone-related problems,
    similar to PCOS and uterine fibroids. Hormone testing entails analyzing blood,
    urine, or saliva samples to measure hormone levels.

    It helps diagnose hormonal imbalances, monitor situations,
    and guide remedy. Common hormones examined embody thyroid, reproductive, and adrenal hormones.

    If ovarian tumors are responsible, surgical intervention may be necessary.

  2. While analysis is still ongoing, it’s clear that hormonal imbalances, including low testosterone, can play a task in coronary
    heart well being. Ladies with low testosterone ought to
    speak to their doctor about managing cardiovascular risks, especially in the
    event that they have already got excessive ldl cholesterol or a family
    historical past of heart illness. Treating low testosterone may assist enhance a few of these
    metabolic issues. Along with life-style adjustments, similar to consuming a
    balanced food plan and exercising frequently, hormone therapy may assist regulate fat
    and vitality storage. If low testosterone is recognized and treated early, it could possibly assist defend bone well being and scale back
    the risk of osteoporosis. Medical Doctors can also recommend calcium and vitamin D supplements, along with weight-bearing workouts, to maintain bones robust.

    Testosterone alternative therapy will suppress sperm formation and decrease fertility.
    The benefits and dangers of utilizing testosterone substitute therapy have to be heavily thought of before therapy
    begins. There are several therapy options for low testosterone, and medications aren’t all the time
    necessary. Altering certain life-style components, such as exercising,
    reducing stress, bettering sleep and bettering dietary
    habits, will help considerably. Many folks
    profit from reducing weight or getting a sleep study and utilizing a CPAP
    machine, which delivers steady air via a hose connected to a mask or nosepiece
    that can assist you sleep. Typically men will come to my office complaining that they have erectile dysfunction and are feeling
    excessively fatigued, weaker or depressed.
    It’s a common myth that women do not need testosterone
    or that having testosterone makes a lady extra “masculine.” This is not true.
    Ladies naturally have testosterone, and it is a necessary
    hormone for his or her health. Issues come up solely when testosterone levels become too
    excessive or too low. This article will focus on the causes of
    low testosterone levels in young males, along with treatment options.

    While a lowered sex drive may also be due to age, low testosterone is thought to cause a major decrease in a man’s want to have intercourse.
    Way Of Life selections additionally play a significant function in testosterone decline.
    Extreme alcohol consumption can impair liver function and disrupt hormone metabolism, whereas smoking has been linked to decreased testicular function.
    A sedentary lifestyle, significantly the absence of energy training and common physical
    exercise, contributes to declining testosterone over time.

    There are totally different forms of testosterone levels you can measure, but checks usually measure whole testosterone.

    These checks measure testosterone connected to proteins and free testosterone—testosterone not sure to active proteins in your tissues.
    Nonetheless, low testosterone alone just isn’t normally
    the primary cause of erectile dysfunction.
    It can have an result on your overall quality of life, leading to frustration or a sense of being “off.” Extra body fat, particularly across
    the neck and higher physique, can put strain on the
    airway, making it more likely to collapse during sleep.
    This is one purpose why are anabolic steroids illegal men with
    Low T who are overweight could expertise more extreme
    sleep apnea signs. Low T is a situation that can affect men of all
    ages, though it is more widespread as they get older.
    It can result in a big selection of signs, from fatigue to temper adjustments, and may have a significant impression on every day
    life. Recognizing the signs of Low T and understanding its causes
    is the primary step in managing the condition. Testosterone remedy carries some risks like zits, sleep
    apnea development however most are mitigated with acceptable dosing and
    monitoring.
    Likewise, decrease testosterone ranges might trigger
    elevated cortisol levels, worsening the body’s stress responses, and raising the chance of tension. As A End
    Result Of testosterone has several key functions across the body’s energy processes, when ranges of this hormone are low, many physiological
    processes are affected. Testosterone is
    central to several bodily and emotional processes.
    When ranges of this hormone fall too low, this will cause noticeable adjustments in well being and
    well-being. However, many males with low t report no important impact on their daily life – making it necessary to determine how signs can differ.
    Additionally, some research reveals that testosterone therapy can enhance your risk of coronary heart illness.
    Testosterone therapy might help reverse the results of hypogonadism, however
    it’s unclear whether or not testosterone therapy would benefit older
    males who’re otherwise healthy.
    TRT can also be available as injections, pores and skin patches, and pellets placed under the skin. In Accordance to a 2019
    review, testosterone supplementation could improve memory in older men with
    low testosterone although the effect may be small.

    Consuming a balanced food regimen wealthy in entire meals, exercising often, and getting enough
    sleep are important. Avoiding smoking, limiting alcohol consumption, and
    managing stress are equally important. Regular medical check-ups
    can help detect hormonal imbalances early, allowing for
    prompt action to stop more serious well being consequences.

  3. Mit einem ungesunden Ernährungsstil ist es schwieriger, den Körper mit Nährstoffen zu versorgen, die für
    eine normale Produktion von testosteron po terminie [recruitment.talentsmine.net] notwendig sind.
    Nüsse können den Testosteronspiegel senken, da sie
    reich an Phytoöstrogenen sind. Diese Substanzen imitieren Östrogen und wirken offenbar als
    Gegenspieler des Testosterons. Es ist auch wichtig, dass man viel Flüssigkeit trinkt, am besten Wasser
    oder ungesüßten Tee, um den Körper hydriert zu halten und damit
    die Hormonproduktion nicht beeinträchtigt wird. Der männliche Körper braucht Testosteron, um Muskelmasse und Kraft aufzubauen, Durchhaltevermögen zu verbessern sowie die sexuelle Funktion und das allgemeine Wohlbefinden zu unterstützen. Auch Frauen produzieren Testosteron, wenn auch in viel geringeren Mengen als Männer.
    Für Frauen ist es ebenfalls wichtig, da es verantwortlich
    ist für Muskelmasse, Knochenstärke und sexuelle Funktion.
    Schauen Sie sich unsere von Experten zusammengestellte Liste der besten Pre-Workout-Sporternährungsprodukte an, um die
    Energie zu steigern, die Konzentration zu verbessern und die Ausdauer zu verbessern. Chronischer Stress
    kann sich negativ auf den Hormonhaushalt
    auswirken und unter anderem den Testosteronspiegel senken. Techniken zur Stressbewältigung wie Meditation und
    Yoga können dabei helfen, einen gesunden Testosteronspiegel aufrechtzuerhalten.
    Die Macawurzel (Lepidium meyenii) ist ein adaptogenes Kraut,
    das in den Anden in Südamerika angebaut wird und in Höhen von 4000 bis 5000
    m über dem Meeresspiegel wächst. Maca, dass traditionell von den Inkas verwendet wurde,
    war für seine zahlreichen medizinischen Vorteile bekannt und wurde hauptsächlich zur Verbesserung der Libido und der Fruchtbarkeit eingesetzt.
    Eine Studie aus dem Jahr 2015 umfasste 57 Männer, die acht
    Wochen lang entweder eine Placebopille oder Ashwagandha erhielten.
    PCT hilft dabei, Ihre natürliche Hormonproduktion zu normalisieren, einschließlich
    Ihres endogenen Testosteronspiegels, der normalerweise durch die Einnahme von Testosteronpräparaten unterdrückt wird.

    Aufgrund der erhöhten Proteinsynthese in Ihrem Muskelgewebe erholen Sie sich während Ihrer Ruhetage oder in der Nebensaison tendenziell schnell von Muskelverletzungen.#3.
    Erhöhte KnochendichteTestosteronpräparate fördern auch die Knochendichte, indem sie die Kollagenproduktion steigern. Neue Forschungen bei übergewichtigen Männern deuten darauf hin, dass eine erhöhte körperliche
    Aktivität zur Erhöhung des Testosteronspiegels noch vorteilhafter struggle als eine Diät zur Gewichtsabnahme.
    Krillöl erfreut sich als Nahrungsergänzungsmittel großer Beliebtheit, da es
    unglaublich gesundheitsfördernd wirkt. Dieses Öl wird aus
    winzigen Krustentieren namens Krill gewonnen und
    ist vollgepackt mit wichtigen Nährstoffen wie Omega-3-Fettsäuren, Phospholipiden und
    Astaxanthin. Ob Sie nun Ihre Herzgesundheit stärken oder Ihre
    Haut verbessern möchten, Krillöl bietet zahlreiche Vorteile.

    Dunkle Augenringe können Sie müde und älter aussehen lassen,
    als Sie sich fühlen, und werfen einen Schatten auf Ihre lebhafte
    Persönlichkeit. Ob sie nun durch schlaflose Nächte, genetische Faktoren oder den Stress
    des Alltags verursacht werden, sie sind ein weit verbreitetes Schönheitsproblem.
    Das chronische Erschöpfungssyndrom (CFS) ist eine lähmende Erkrankung,
    die durch anhaltende Müdigkeit gekennzeichnet ist, die sich durch Ruhe nicht bessert.
    Es betrifft Millionen von Menschen weltweit und kann das tägliche Leben stark beeinträchtigen. Für Menschen, die mit chronischer Müdigkeit zu kämpfen haben, ist es von entscheidender Bedeutung,
    die Ursachen und Behandlungsmöglichkeiten zu verstehen.
    Dies ist ein Problem, da starke Studien einen Zusammenhang zwischen niedrigem Testosteron und Fettleibigkeit,
    erhöhtem Krankheitsrisiko und vorzeitigem Tod zeigen. Ab einem Alter von 25 bis 30
    Jahren beginnt der Testosteronspiegel eines Mannes auf
    natürliche Weise zu sinken. Es ist wahrscheinlich keine Überraschung, dass übermäßiger Alkohol- oder Drogenkonsum, sei es medizinisch oder als Freizeitbeschäftigung, auch den Testosteronspiegel senken kann.
    Eine hohe Exposition gegenüber östrogenähnlichen Chemikalien kann sich ebenfalls auf Ihren Spiegel auswirken. Versuchen Sie daher, die tägliche Exposition gegenüber BPA,
    Parabenen und anderen Chemikalien, die in einigen Kunststoffarten vorkommen, zu minimieren.
    Eine Langzeitstudie beobachtete, dass diejenigen, die nur vier Stunden pro Nacht schliefen, grenzwertige
    Mangelwerte hatten.
    Den Gesamttestosteronspiegel, das luteinisierende Hormon und das follikelstimulierende Hormon, um
    Ihren natürlichen Hormonspiegel zu bestimmen und zu
    entscheiden, ob Sie eine Testosteronersatztherapie benötigen. Es kann einen Mangel
    ausgleichen und sogar zu einem erhöhten Testosteronspiegel
    beitragen. Täglich mindestens 15 Minuten direkte Sonneneinstrahlung können dazu beitragen, den Vitamin-D-Spiegel aufrechtzuerhalten.
    Die Ergebnisse zeigten, dass diejenigen, die das Kraut einnahmen, einen Anstieg ihrer
    Testosteronwerte im Vergleich zu denen hatten, die das Placebo einnahmen. Zufolge
    einer anderen Studie von 1999, veröffentlicht in Urologia Internationalis,
    waren Dosen von 1.500 mg pro Tag jedoch nicht wirksam.
    Aufgrund der Bedenken hinsichtlich der Nebenwirkungen und
    der Kosten von Medikamenten werden viele nach natürlichen Alternativen suchen, wie im Folgenden beschrieben wird.

    Es gibt Medikamente, die von pharmazeutischen Unternehmen speziell zur Behandlung der
    erektilen Dysfunktion entwickelt wurden. Dazu gehören Sildenafil (Viagra), Tadalafil (Cialis) und Vardenafil (Levitra).
    Diese Medikamente können wiederum für viele hilfreich sein, ich habe sie selbst häufig verschrieben. Der Versuch, die Ursache des Problems
    zu finden und die Gesundheit und das Gleichgewicht
    wiederherzustellen, sollte jedoch sowohl für den Patienten als auch
    für den Arzt das vorrangige Ziel sein.
    Darüber hinaus trägt Übergewicht dazu bei, den Testosteronspiegel bei
    Männern zu senken, was in erster Linie darauf zurückzuführen ist,
    dass Fettgewebe das Testosteron eines Mannes in Östrogen umwandelt.
    Schlaf spielt eine entscheidende Rolle für die Aufrechterhaltung eines
    ausgewogenen Testosteronspiegels. Ausreichender und qualitativ hochwertiger
    Schlaf hilft, das Hormongleichgewicht zu fördern und unterstützt das emotionale Wohlbefinden.
    Ja, regelmäßige körperliche Bewegung kann den Testosteronspiegel positiv beeinflussen. Sie hilft nicht nur beim Stressabbau,
    sondern kann auch direkt zur Stabilisierung des
    Hormonhaushalts beitragen.
    Mit zunehmendem Alter kann der Testosteronspiegel bei Männern allmählich sinken. Dieser natürliche Rückgang beginnt etwa
    im mittleren Alter und kann zu Symptomen der Andropause führen, ähnlich
    der Menopause bei Frauen, wie z. Einige natürliche Nahrungsergänzungsmittel können den Testosteronspiegel erhöhen, darunter Bockshornklee,
    Dehydroepiandrosteron (DHEA) und Ashwagandha.

Leave a Reply

Your email address will not be published. Required fields are marked *

RELATED POST

How to automatically restart Linux services with Systemd

Getting your Linux deployments working reliably is of paramount concern for production applications. One way to guarantee that a service…

How to Install SFTPGo on Ubuntu 22.04

Setup UFW Firewall For security reasons, it is recommended to install and configure the UFW firewall in your system. First,…

Executing Bash Scripts at Startup in Ubuntu Linux

Creating a Bash script in Ubuntu To create a Bash script in Ubuntu, you can use any text editor of…

How To Clear PHP’s Opcache

PHP can be configured to store precompiled bytecode in shared memory, called Opcache. It prevents the loading and parsing of PHP…