How to use NGINX as a reverse proxy for Apache – TechRepublic

Jack Wallen walks you through the process of setting up NGINX such that it will direct incoming port 80 traffic to Apache, listening on port 8080.

network-switch-cover-a-stockphoto-copy.jpg

NGINX is an incredibly fast web server. Apache is an incredibly powerful web server. Both have pros and cons, so sometimes it can be a challenge to decide which one to choose.

What if I told you that you can get the best of both worlds? The speed of NGINX and the power of Apache. 

More about Networking

You do that by configuring NGINX as a reverse proxy for Apache. With this setup, NGINX will listen for all incoming requests to port 80 and pass them on to Apache, which is listening in on port 8080.

I’m going to show you how to do that very thing on Ubuntu Server 20.04. I’ll be demonstrating a very basic setup.

SEE: Linux service control commands (TechRepublic Premium)

What you’ll need

  • A running instance of Ubuntu Server 20.04
  • A user with sudo privileges

How to install and configure Apache

The first thing we’ll do is install and configure Apache. To install the web server, log in to Ubuntu and issue the command:

sudo apt-get install apache2 -y

Once the server is installed, you’ll need to configure it to listen to port 8080 (instead of the default 80). To do that, issue the command:

sudo nano /etc/apache2/ports.conf

In that file, look for the line:

Listen 80

Change that line to:

Listen 8080

Save and close the file.

Now you can start and enable Apache with the commands:

sudo systemctl start apache2
sudo systemctl enable apache2

How to install and configure NGINX

We can now install NGINX with the command:

sudo apt-get install nginx -y

Once NGINX has been installed, we’ll create a proxy configuration with the command:

sudo nano /etc/nginx/conf.d/proxy.conf

In that file, paste the following:

server { listen 80; server_name test.example.com; location ~ \.php$ { proxy_pass http://SERVER:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }
}

Where SERVER is the IP address of your hosting server. Save and close the file.

Start and enable NGINX with the commands:

sudo systemctl start nginx
sudo systemctl enable nginx

Create a test HTML file with the command:

sudo nano /var/www/html/test.html

In that file, paste the following:

!DOCTYPE html>
<html>
<body>
<h1>Apache</h1>
<p>by way of NGINX</p>
</body>
</html>

Save and close the file. 

Remember, NGINX is listening to port 80 and Apache is listening to port 8080. If you open a browser and point it to http://SERVER:8080/test.html (where SERVER is the IP address of the hosting server) you’ll see the test page (Figure A).

Figure A

Our test.html page in all it’s basic glory, served by Apache on port 8080.

” data-credit>proxya.jpgproxya.jpg

Our test.html page in all it’s basic glory, served by Apache on port 8080.

If you point the browser to http://SERVER/test.html (where SERVER is the IP address of the hosting server), you’ll see the same page. NGINX is successfully passing incoming port 80 traffic to port 8080.

And that’s all there is to setting up a basic NGINX reverse proxy for Apache.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Also see

Source of this news: https://www.techrepublic.com/article/how-to-use-nginx-as-a-reverse-proxy-for-apache/

Related posts:

Your Data-Driven Business Is Missing Something - A Proxy - Analytics Insight
You’ll be surprised to know the advantages a proxy can bring to your business.What’s the first thing that comes to your mind when you read Unblocking Netflix from another country? There are other use...
Turning Thousands Of Minecraft Players On The Same Server - Hackaday
Multi-threading was the approved go-to technique for extracting good deal more performance from a machine for quite some time. These days it’s all about horizontal scaling or adding more electron...
Livedrive Review | Cheap & easy to use, but it lacks features - ProPrivacy
Pricing LiveDrive is a cloud backup service that can be purchased either for personal backup requirements or by businesses for commercial backups. The service offers three different plans for consume...
Tests WebSockets with Burp Apartment - The Daily Swig
QUALITY WebSockets are long-lived connections of support asynchronous communication in both directions. Burp Suite characteristics rich set of tools to support protection testing WebSockets...
Why You Suddenly Need To Delete Gmail On Your iPhone - Forbes
Yet again this week we have seen headlines pitching Apple against Facebook, as the iPhone maker’s crackdown on user tracking threatens mobile ad revenues. But while Facebook is clearly in Apple’s sig...
How to Fix 'Microsoft Store Freezing' Issue on Windows 10 PC - BollyInside
This tutorial is about the How to Fix ‘Microsoft Store Freez­ing’ Issue on Win­dows 10 PC. We will try our best so that you understand this guide. I hope you like this blog How to Fix ‘Microsoft...
Alta Turismo 7 Appears from Nvidia GeForce Now Outflow (Updated) - GTPlanet
Algorithm change: Nvidia contains responded to the leak, exclaiming that the list of titles to your platform is “used just for internal tracking and testing”, and that the inclusion of a lot ...
Dustin May Has Finally Discovered His Strikeouts - FanGraphs
The quality of Dustin May’s raw stuff is undeniable. He throws his sinker with the highest average velocity of any starter in the majors and it’s ridiculous tailing action makes it one of the most GI...
How to fix Windows Update error 0x80242016 - TWCN Tech News
Here is a guide to fix Windows Update error 0x80242016. Windows Update errors are not new as users keep running into one or another update error every now and then. One such error is the error code 0...
Maryland’s COVID positivity rate sinks new low as hot cases, hospitalizations continue to labor - Ba...
With relevant to 26, 000 people, Somerset also ranked last when it came to the share of its amount to receive a first vaccine portion, 32. 9%, the data shows and videos. Not far ahead is another ...
New-fangled Payment Data Stealing Spyware and adware Hides in Nginx Action on Linux Servers how to p...
Commerce en ligne platforms in the U. S i9000., Germany, and France came under attack from a new malware that targets Nginx servers in an attempt to masquerade have any presence and slip ago de...
Assay for the sensitive and specific identification of SARS-CoV-2 Delta variant - News-Medical.Net
The Delta variant (B.1.617.2) of severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) was first detected in India and is currently replacing the variants circulating in Europe, the USA, and m...
How to Fix the Microsoft Store Acquiring License Error 2021 Tips - Bollyinside - BollyInside
This tutorial is about the How to Fix the Microsoft Store Acquiring License Error. We will try our best so that you understand this guide. I hope you like this blog How to Fix the Microsoft Store Acq...
A bit more children are going to the hospital mainly because of the delta variant. But friends and ...
Sophia Gomez, 9, at home in Doral, Fla., on Aug. 6, 2021, after being hospitalized because six days with COVID-19. "I didn't think that tiny could get that sick, alone said her mother, Hito Villa...
Exchange Servers Under Active Attack via ProxyShell Bugs - Threatpost
The administrator of your personal data will be Threatpost, Inc., 500 Unicorn Park, Woburn, MA 01801. Detailed information on the processing of personal data can be found in the privacy policy. In ad...
iCloud+ Private Relay: How to Prepare it on Mac - Mechanic Times
(Photo: Unsplash/ Christian Wiediger) Mac technique iCloud+ Private Relay is a offer that Apple added relating to its iPhone and sheltered with iOS, as well as by way of iPadOS 15. With th...
Solution: Cannot add PPA: "This PPA does not support focal" in Linux Mint 20 - Linux News - BollyIns...
If you are adding PPA repo in Linux mint 20.02 and getting an error Cannot add PPA: ”This PPA does not support focal”. Then follow the simple command given in the article that will solve this error.I...
Rights group says website attacked during commemoration of killings - Philstar.com
MANILA, Philippines — Local human rights watchdog Karapatan on Thursday decried renewed cyberattacks against its website at karapatan.org. In a statement, the rights group said this ca...

IP Rotating Proxy Onsale

SPECIAL LIMITED TIME OFFER

00
Months
00
Days
00
Hours
00
Minutes
00
Seconds
First month free with coupon code FREE30