Setup nginx_apache reverse proxy

Patient Tools

Read, save, and share this guide

Use these quick tools to make this medical article easier to read, print, save, or share with a family member.

Medical guide PHP, JS, CSS, Python, and Machine Learning Technology Feb 8, 2026 13 reads
Related reading

Patient Mode

Understand this article easily

Switch between simple English and easy Bangla patient notes. This is for education and does not replace a doctor consultation.

With the nginx_apache reverse proxy, static files are served by Nginx and PHP files are processed by Apache, thus overall performance is improved. And yes, the setup is fully compatible with .htaccess files. In general, the schema is: A new connection arrives and Nginx handles...

For severe symptoms, danger signs, pregnancy, child illness, or sudden worsening, seek urgent medical care.

বাংলা রোগী নোট এখনো যোগ করা হয়নি। পোস্ট এডিটরে “RX Bangla Patient Mode” বক্স থেকে সহজ বাংলা সারাংশ যোগ করুন।

এই তথ্য শিক্ষা ও সচেতনতার জন্য। এটি ডাক্তারি পরীক্ষা, রোগ নির্ণয় বা প্রেসক্রিপশনের বিকল্প নয়।

Article Summary

With the nginx_apache reverse proxy, static files are served by Nginx and PHP files are processed by Apache, thus overall performance is improved. And yes, the setup is fully compatible with .htaccess files. In general, the schema is: A new connection arrives and Nginx handles it. If it is for a static file (not a PHP script), go to step 2, else go to step...

Key Takeaways

  • This article explains Customizing NGINX/APACHE in simple medical language.
  • This article explains Global custom include templates for Apache/Nginx in simple medical language.
  • This article explains Global pre/post per-file before each Apache/Nginx CUSTOMX token in simple medical language.
  • This article explains Global pre/post file before each apache/nginx template in simple medical language.
Educational health guideWritten for patient understanding and clinical awareness.
Reviewed content workflowUse writer and reviewer profiles for stronger trust.
Emergency safety firstUrgent warning signs are highlighted below.

Seek urgent medical care if you notice

These warning signs are general safety guidance. Local emergency numbers and clinical judgment should always come first.

  • Severe symptoms, breathing difficulty, fainting, confusion, or rapidly worsening illness.
  • New weakness, severe pain, high fever, or symptoms after a serious injury.
  • Any symptom that feels urgent, unusual, or unsafe for the patient.
1

Emergency now

Use emergency care for severe, sudden, rapidly worsening, or life-threatening symptoms.

2

See a doctor

Book a professional medical evaluation if symptoms persist, worsen, recur often, affect daily activities, or occur in a high-risk patient.

3

Learn safely

Use this article to understand possible causes, tests, treatment options, prevention, and questions to ask your clinician.

Before reading

RX Patient Tools

Use these quick guides before reading the article, or return to them when you need help preparing questions for a doctor.

Start here Choose the right pathway for symptoms, reports, medicines, or urgent warning signs. Disease article roadmap Read this topic step by step: meaning, symptoms, warning signs, diagnosis, treatment, prevention, and follow-up. Treatment planner Prepare questions about treatment choices, benefits, risks, side effects, and follow-up. Family & caregiver guide Organize symptoms, reports, medicines, questions, and follow-up safely. Nutrition & diet guide Prepare food, hydration, supplement, and medicine-timing questions safely. Prevention guide Organize risk factors, protective habits, screening, and warning signs. Recovery guide Prepare a safe plan for activity, rehabilitation, warning signs, and follow-up.
Definition

With the nginx_apache reverse proxy, static files are served by Nginx and PHP files are processed by Apache, thus overall performance is improved.

And yes, the setup is fully compatible with .htaccess files.

In general, the schema is:

  1. A new connection arrives and Nginx handles it. If it is for a static file (not a PHP script), go to step 2, else go to step 3.
  2. Nginx serves the static file to the user.
  3. Nginx forwards the file to Apache. Go to 4.
  4. Apache handles the PHP request – it tells PHP-FPM to compile it (if it is in FPM mode). Go to 5.
  5. Apache returns the output of the script to Nginx. Go to 6.
  6. Nginx returns the file back to the user.

To install nginx_apache, do the following:

cd /usr/local/directadmin/custombuild
./build update
./build update_da
./build set webserver nginx_apache
./build nginx_apache
./build rewrite_confs

As Nginx and Apache are working simultaneously, if any modifications are necessary (such as the creation of a wildcard subdomain, automatic Webmail subdomains, etc), you must apply the necessary edits to both Nginx and Apache. Use appropriate sections in this guide for instructions.

Customizing NGINX/APACHE

per-domain nginx=1 (disable proxy) for nginx-only processing with Nginx reverse proxy

If you’re running with custombuild options.conf setting:

webserver=nginx_apache

where apache is behind an nginx proxy, then by default all domains are listed in both the User nginx.conf and httpd.conf. All connections run through the nginx.conf, and some requests are passed through to apache as needed, while static files are processed by nginx.

This feature lets you shut off the proxy part, just for 1 domain, such that the domain is procssed 100% by nginx, without using apache at all. PHP is still enabled for the nginx-only domain (must use php-fpm just like standalone nginx).

To enable this for a given domain, add:

nginx=1

to the domain’s config in:

/usr/local/directadmin/data/users/FRED/domains/DOMAIN.COM.conf

and issue a rewrite: /usr/local/directadmin/custombuild/build rewrite_confs

Relative CMD_* calls and JSON

To view the state of a domain:

CMD_ADDITIONAL_DOMAINS?action=view&domain=testdomain%2Ecom&ipp=50&json=yes&redirect=yes

Which is a dump of the domain.com.conf file, and will include this if enabled:

nginx=1

Additionally, HAS_PER_DOMAIN_NGINX=yes will be shown if this value is allowed to be controlled.

To save the setting:

CMD_DOMAIN
method: POST
action=modify
domain=testdomain.com
form_version=1.1
...
nginx=1

Which is to be saved along with all other settings (php, cgi, etc), OR you can save just this item:

method: POST
action=modify
domain=testdomain.com
only_affect=nginx
nginx=1

Disabling is the same as enabling, except pass either:

nginx=0

or simply omit the nginx variable entirely, as it is a checkbox and the absence is the equivalent to ‘off’.

Relative skin changes

The following skin file:

/usr/local/directadmin/data/skins/enhanced/user/modify_domain.html

Now contains the following after php:

|*if HAS_PER_DOMAIN_NGINX="yes"|
        <tr>
            <td>|LANG_NGINX_ONLY|</td>
            <td align=center><input type="checkbox" name="nginx" value="1" |NGINX_CHECKED|></td>
            <td>|LANG_NGINX_ONLY_DESC|</td>
        </tr>
|*endif|

Relative Language pack changes

The file:

/usr/local/directadmin/data/skins/enhanced/lang/en/user/modify_domain.html

Now contains the following:

LANG_NGINX_ONLY=Nginx-Only
LANG_NGINX_ONLY_DESC=Use only Nginx. Proxy to apache is disabled.

Global custom include templates for Apache/Nginx

This feature will let you insert global custom values into the CUSTOM and CUSTOM# variables in the Apache/Nginx templates. You can think of this as a virtual_host2.conf subset template, that is only used if it exists, and gets inserted into the CUSTOM tokens for all VirtualHosts.

It would be handy if you want add code to all VirtualHosts, but don’t want to create new templates, and don’t want to add it to each domain’s Custom Httpd Config.

Add the new custom template token files to the data/templates/custom folder, matching the token name you want, with a .pre or .post suffix e.g.,

/usr/local/directadmin/data/templates/custom/cust_httpd.CUSTOM.3.pre/usr/local/directadmin/data/templates/custom/cust_httpd.CUSTOM.post/usr/local/directadmin/data/templates/custom/cust_httpd.CUSTOM.2.post/usr/local/directadmin/data/templates/custom/cust_nginx.CUSTOM.post

with the Apache/Nginx code that you want to be inserted to the given token.

The prefix is either cust_httpd. or cust_nginx. to determine which server type the token is for.

Where .pre means that your code would be added before any CUSTOM/CUSTOM.# values set in:

Admin Level -> Custom Httpd Config -> domain.com -> CUSTOM

or .post means it would be added after any Custom Httpd Config data.

You can use tokens as desired.

If you’re not sure if you should use pre or post, keep in mind that tokens can be set in Custom Httpd Config, so you could then read them if they’re set and alter the behavior of your CUSTOM.post using if-then-else statements.

Global pre/post per-file before each Apache/Nginx CUSTOMX token

Very similar to the feature mentioned earlier, this variation does the same thing, but not for all templates, but rather for the specific template that is named.

All are located inside this directory:

/usr/local/directadmin/data/templates/custom/

And include:

virtual_host2.conf.CUSTOM.prenginx_server.conf.CUSTOM.4.postvirtual_host2_secure_sub.conf.CUSTOM.1.pre etc.

Where the format is:

<templatename>.<tokenname>.<pre|post>

Note these per-template token files are included before the “Global custom include templates for Apache/Nginx” files, which are still included, if both exist.

ALSO at the start/end of the entire httpd.conf or nginx.conf file, unrelated to any VirtualHost or CUSTOM token:

/usr/local/directadmin/data/templates/custom/cust_httpd.pre/usr/local/directadmin/data/templates/custom/cust_httpd.post/usr/local/directadmin/data/templates/custom/cust_nginx.pre/usr/local/directadmin/data/templates/custom/cust_nginx.post

which shows up just after the comments, before the user_virtual_host.conf, and at the very end of the .conf files. Note that these start/end .conf templates do not share the token files like per-domains do, so you cannot pass variables around in the same way. However, like all Apache/Nginx templates, they run as root, and they have embedded scripting abilities, so you can read or write data to disk, even a database, and control things that way.

Global pre/post file before each apache/nginx template

For the main domain http/https/subomain templates, you can now create custom template files that will be tokenized and inserted outside of the VirtualHost/server{} entry.

For example, if you want code before all main virtual_host2.conf templates, create:

/usr/local/directadmin/data/templates/custom/virtual_host2.conf.pre

with the code you want, and it will show up before all VirtualHosts from that given template.

This can be repeated for other template files:

nginx_server_secure_sub.confnginx_server_secure.confvirtual_host2_secure_sub.confvirtual_host2_secure.confnginx_server_secure.confnginx_server.confvirtual_host2_secure.confvirtual_host2.conf

How to install the Pagespeed module

Mod_pagespeed is an open-source Apache HTTP Server (or Nginx) module, which automatically applies chosen filters to pages and associated assets such as stylesheets, JavaScript, and HTML files, as well as to images and website cache requirements.

A major advantage of this module is that it does not require modifications to existing content or workflow, meaning that all internal optimizations and changes to files are made on the server side, presenting modified files directly to the user. Each of 40+ filters correspond to one of Google’s web performance best practices rules.

If nginx_apache reverse proxy is used, one could install the Pagespeed module for Nginx only. To do so, follow the guide from the “Nginx > Customizing NGINX” section.

How to enable brotli compression

  1. Extract brotli under any path you prefer. In this case I chose to to extract it in the base of the custombuild directory.
cd /usr/local/directadmin/custombuild
mkdir brotli
git clone https://github.com/google/ngx_brotli.git brotli
cd brotli && git submodule update --init && cd ..
  1. Add a custom add-module directive.
mkdir -p custom/nginx_reverse
cp -p ./configure/nginx_reverse/configure.nginx custom/nginx_reverse/

Add the following somewhere before the last configuration line in custom/nginx_reverse/configure.nginx.

"--add-module=/usr/local/directadmin/custombuild/brotli" \

make sure to substitute /usr/local/directadmin/custombuild/brotli with whatever path it’s been extracted under.

  1. rebuild nginx_apache
./build update
./build nginx_apache

This should have compiled nginx with the brotli module.

You can configure brotli by modifying /etc/nginx/nginx-includes.conf. Refer to the documentation found hereopen in new window.

  1. To test that the configuration was successful, add the following to /etc/nginx/nginx-includes.conf:
brotli on;
brotli_static on;
service nginx restart

curl one of your domains (exampledomain.com in this example).

curl -kL -I -H 'Accept-Encoding: br' http://exampledomain.com 2>&1 | grep -i encoding

If successful, the following output should be returned:

Content-Encoding: br
,

Doctor visit helper

Prepare before seeing a doctor

A simple rural-patient checklist to help you explain symptoms clearly, ask better questions, and avoid unsafe self-treatment.

Safety note: This is not a prescription or diagnosis. For severe symptoms, pregnancy danger signs, children with serious illness, chest pain, breathing difficulty, stroke-like weakness, or major injury, seek urgent care.

Which doctor may help?

Start with a registered doctor or the nearest qualified health center.

What to tell the doctor

  • Write when the problem started and how it changed.
  • Bring old prescriptions, investigation reports, and current medicines.
  • Write allergies, pregnancy status, diabetes, kidney/liver disease, and major past illnesses.
  • Bring one family member if the patient is weak, elderly, confused, or a child.

Questions to ask

  • What is the most likely cause of my symptoms?
  • Which danger signs mean I should go to hospital quickly?
  • Which tests are necessary now, and which can wait?
  • How should I take medicines safely and what side effects should I watch for?
  • When should I come for follow-up?

Tests to discuss

  • Vital signs: temperature, pulse, blood pressure, oxygen saturation
  • Basic physical examination by a clinician
  • CBC, urine test, blood sugar, or imaging only when clinically needed

Avoid these mistakes

  • Do not use antibiotics, steroid tablets/injections, or strong painkillers without proper medical advice.
  • Do not hide pregnancy, kidney disease, ulcer, allergy, or blood thinner use.
  • Do not delay emergency care when danger signs are present.

Medicine safety and first-aid guide

This section is for patient education only. It does not replace a doctor, pharmacist, or emergency care.

Safe first steps

  • Rest, drink safe water, and observe symptoms carefully.
  • Keep a written note of symptoms, duration, temperature, medicines already taken, and allergy history.
  • Seek medical care quickly if symptoms are severe, worsening, or unusual for the patient.

OTC medicine safety

  • For mild pain or fever, ask a registered pharmacist or doctor before using common over-the-counter pain/fever medicines.
  • Do not combine multiple pain medicines without advice, especially if you have kidney disease, liver disease, stomach ulcer, asthma, pregnancy, or take blood thinners.
  • Do not give adult medicines to children unless a qualified clinician advises it.

Avoid these mistakes

  • Do not start antibiotics without a proper medical decision.
  • Do not use steroid tablets or injections casually for quick relief.
  • Do not delay emergency care because of home remedies.

Get urgent help if

  • Severe symptoms, confusion, fainting, breathing difficulty, chest pain, severe dehydration, or sudden weakness need urgent medical care.
Medicine names, dose, and timing must be decided by a qualified clinician or pharmacist after checking age, pregnancy, allergy, other diseases, and current medicines.

For rural patients and family caregivers

Patient health record and symptom diary

Write your symptoms, medicines already taken, test results, and questions before visiting a doctor. This note stays on your device unless you print or copy it.

Doctor to discuss: Doctor / qualified healthcare provider
Tests to discuss with doctor
  • Basic vital signs: temperature, pulse, blood pressure, oxygen level if needed
  • Relevant blood, urine, imaging, or specialist tests only after clinical assessment
Questions to ask
  • What is the most likely cause of my symptoms?
  • Which warning signs mean I should go to emergency care?
  • Which tests are really needed now?
  • Which medicines are safe for my age, pregnancy status, allergy, kidney/liver/stomach condition, and current medicines?

Emergency warning signs such as chest pain, severe breathing difficulty, sudden weakness, confusion, severe dehydration, major injury, or loss of bladder/bowel control need urgent medical care. Do not wait for online information.

Safe pathway to proper treatment

Care roadmap for: Setup nginx_apache reverse proxy

Use this simple roadmap to understand the next safe steps. It is educational and does not replace examination by a doctor.

Go to emergency care if you notice:
  • Severe or rapidly worsening symptoms
  • Breathing difficulty, chest pain, fainting, confusion, severe weakness, major injury, or severe dehydration
Doctor / service to discuss: Qualified healthcare provider; specialist depends on symptoms and examination.
  1. Step 1

    Check danger signs first

    If danger signs are present, seek emergency care and do not wait for online information.

  2. Step 2

    Record the symptom story

    Write when symptoms started, severity, medicines already taken, allergies, pregnancy status, and test results.

  3. Step 3

    Visit a qualified clinician

    A doctor, nurse, or qualified healthcare provider can examine you and decide which tests or treatment are needed.

  4. Step 4

    Do only useful tests

    Do tests after clinical assessment. Avoid unnecessary tests, random antibiotics, or repeated medicines without diagnosis.

  5. Step 5

    Follow up and return early if worse

    If symptoms worsen, new warning signs appear, or treatment is not helping, return for review quickly.

Rural patient practical tips
  • Take a written symptom diary and all previous prescriptions/test reports.
  • Do not hide medicines already taken, even herbal or over-the-counter medicines.
  • Ask which warning signs mean urgent referral to hospital.

This roadmap is for education. A real diagnosis and treatment plan requires history, examination, and clinical judgment.

RX Patient Help

Ask a health question safely

Write your symptom story. A health professional or site editor can review it before any answer is prepared. This box is not for emergency care.

Emergency first: Severe chest pain, breathing trouble, unconsciousness, stroke signs, severe injury, heavy bleeding, or rapidly worsening symptoms need urgent local medical care now.

Frequently Asked Questions

Is this article a replacement for a doctor?

No. It is educational content only. Patients should consult a qualified clinician for diagnosis and treatment.

When should I seek urgent care?

Seek urgent care for severe symptoms, rapidly worsening condition, breathing difficulty, severe pain, neurological changes, or any emergency warning sign.

A global war against illness

Help this medical guide reach someone who may need it

Share reliable health information with a patient, family member, caregiver, or colleague. Reading and awareness can help people ask better questions and seek appropriate care.

Continue exploring

Explore this topic across the RX Medical Library

Open a focused A–Z pathway or continue with closely related indexed articles. These links are educational and do not replace personal medical care.

Search this topic
Diseases A–Z Drugs A–Z Lab Tests A–Z Cancer A–Z
Diseases A–Z

Apache Flink

Apache Flink is an open-source, distributed engine for stateful processing over unbounded (streams) and bounded (batches)…

Diseases A–Z

Apache Hadoop

Apache Hadoop is an open source framework that is used to efficiently store and process large…