• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » How to Add a Nginx Cache Server Infront of Apache Server

By Abhishek Ghosh May 22, 2021 6:12 pm Updated on May 22, 2021

How to Add a Nginx Cache Server Infront of Apache Server

Advertisement

If you have a separate cache server in front of your main server, then you may avoid many of the attacks on the main server plus downtimes of the main server will get masked (although PHP functions of the main site will not work).
We need a cloud server instance from a host which is reliable and has IPv6 support. There are many cloud IaaS providers who are IPv6 capable and sells 1 GB RAM instance at a cheap rate. The main point we need to check is their average response time. A server with a slow response time will harm the perceived page loading speed. When configured as a cache, NGINX can cache both static and dynamic content. It may improve dynamic content performance with micro-caching.

Install Nginx on a fresh server (you’ll find guides on our website like this one). You need the copies of SSL certificate and private key. You can transfer them via FTP or create a compressed file and wget from the other server.

Vim
1
2
3
4
5
6
7
8
9
10
                           AAAA Record
                           A Record
+-------------------+     +---------------------+
| Dedicated Server  |====>| Virtual Server      |   ===> Headers and HTML passed
|                   |     | With IPv4, IPv6     |
|                   |     |  running            |
| With IPv4, IPv6   |     | Nginx reverse proxy |
| running Apache    |     +---------------------+
|                   |
+-------------------+

This is an example configuration to provide you a basic example :

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
## All is kept default except Proxy Configs stanza added to default
## mkdrir -p /var/lib/nginx/cache && sudo chown www-data /var/lib/nginx/cache
## sudo chmod 700 /var/lib/nginx/cache
 
user www-data;
worker_processes auto;
pid /run/nginx.pid;
 
events {
       worker_connections 768;
       # multi_accept on;
}
 
http {
 
       ##
       # Basic Settings
       ##
 
       sendfile on;
       tcp_nopush on;
       tcp_nodelay on;
       keepalive_timeout 65;
       types_hash_max_size 2048;
       # server_tokens off;
 
       # server_names_hash_bucket_size 64;
       # server_name_in_redirect off;
 
       include /etc/nginx/mime.types;
       default_type application/octet-stream;
 
       ##
       # SSL Settings
       ##
 
       ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
       ssl_prefer_server_ciphers on;
 
       ##
       # Logging Settings
       ##
 
       access_log /var/log/nginx/access.log;
       error_log /var/log/nginx/error.log;
 
       ##
       # Gzip Settings
       ##
 
       gzip on;
       gzip_disable "msie6";
 
       # gzip_vary on;
       # gzip_proxied any;
       # gzip_comp_level 6;
       # gzip_buffers 16 8k;
       # gzip_http_version 1.1;
       # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
 
       ##
       # Proxy Configs
       ##
 
             proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=backcache:8m max_size=50m;
              proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";
              proxy_cache_valid 200 302 10m;
              proxy_cache_valid 404 1m;
 
       ##
       # Virtual Host Configs
       ##
       include /etc/nginx/conf.d/*.conf;
       include /etc/nginx/sites-enabled/*;
}

Using proxy_cache_use_stale error timeout http_500; means that when Nginx receives an error from the upstream server and has a stale version of the requested file in the cached content, it delivers that stale file.

How to Add a Nginx Cache Server Infront of Apache Server

You’ll get the official documentations here :

Vim
1
2
3
4
5
6
7
8
# http://nginx.org/en/docs/http/ngx_http_proxy_module.html
# https://www.nginx.com/blog/nginx-caching-guide/
# https://www.nginx.com/resources/wiki/start/topics/examples/reverseproxycachingexample/
### There are many tools these days for Nginx for different reasons:
 
# https://github.com/mahmud-ridwan/loadcat
# https://github.com/schenkd/nginx-ui
# https://nginxproxymanager.com/

This Article Has Been Shared 471 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How to Add a Nginx Cache Server Infront of Apache Server

  • How to Install Virtualmin/Webmin on Ubuntu 16.04

    Many Users Want A Free cPanel Like Web Hosting Control Panel. Virtualmin is Free. Here is How to Install Virtualmin/Webmin on Ubuntu 16.04.

  • How To Install TICK Stack on Ubuntu, CentOS For System Metrics Monitoring

    TICK Stands For Telegraf, InfluxDB, Chronograf, Kapacitor. Here is How To Install TICK Stack on Ubuntu, CentOS For System Metrics Monitoring.

  • How to Install Silex : Static Website Builder on Ubuntu Server

    Silex is a F/OSS Static Website Editor Intended to be Accessed via Browser to Host Sites on Cloud Storages. Here is How to Install Silex Static Website Builder on Ubuntu Server.

  • How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS

    Here is Detailed Guide on How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS With Commands and Configurations For Most Secured Setup.

  • Analysis of Jenkins for DevOps : Part I

    This is Part I of Series Analysis of Jenkins for DevOps. Jenkins is a software system developed for maintaining collaboration, quality management, agility.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Exploring the Benefits and Advantages of Microsoft’s Operating System March 22, 2023
  • Web Design Cookbook: Accessibility March 21, 2023
  • Online Dating: How to Find Your Match March 20, 2023
  • Web Design Cookbook: Logo March 19, 2023
  • How Starlink Internet Works March 17, 2023

About This Article

Cite this article as: Abhishek Ghosh, "How to Add a Nginx Cache Server Infront of Apache Server," in The Customize Windows, May 22, 2021, March 22, 2023, https://thecustomizewindows.com/2021/05/how-to-add-a-nginx-cache-server-infront-of-apache-server/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT