ItSolutionStuff.com

Apache Reverse Proxy with Authentication Example

By Hardik Savani • October 28, 2021
Ubuntu

Today, apache reverse proxy with authentication example is our main topic. In this article, we will implement an apache reverse proxy with basic authentication. In this article, we will implement an apache reverse proxy to add basic authentication. if you have a question about how to add basic authentication in apache reverse proxy then I will give a simple example with a solution.

Sometimes we made a configuration of reverse proxy with port using apache configuration. you basically added ProxyPass and ProxyPassReverse config. it's working fine but anyone can access your IP or domain. If you want to add basic authentication using apache then I will give you simple example commands for the ubuntu server.

Let's see bellow command:

Install apache2-utils

Here, we need to install apache2-utils package.

sudo apt-get install apache2-utils

Set Username and Password

Now, set username and password that you want to keep.

sudo htpasswd -c /etc/apache2/.htpasswd <username>

Add Proxy

Here, we will add Proxy tag for basic authentication.

sudo nano /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>

ProxyPass / http://127.0.0.1:47334/

ProxyPassReverse / http://127.0.0.1:47334/

Timeout 5400

ProxyTimeout 5400

ServerName localhost

<Proxy *>

Order deny,allow

Allow from all

Authtype Basic

Authname "Password Required"

AuthUserFile /etc/apache2/.htpasswd

Require valid-user

</Proxy>

</virtualhost>

Now, let's restart apache2.

sudo service apache2 reload

Now, you can check your IP or domain with basic authentication as bellow:

i hope it can help you...

Tags: Ubuntu
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Install Yarn npm in Ubuntu?

Read Now →

How to Upgrade PHP Version from 7.3 to 7.4 in Ubuntu?

Read Now →

How to Upgrade PHP Version from 7.2 to 7.3 in Ubuntu?

Read Now →

How to Enable Apache mod_rewrite Module in Ubuntu?

Read Now →

Laravel 8 PayPal Integration Tutorial

Read Now →

How to create quick apache virtual host in Ubuntu?

Read Now →

How to create virtual host in ubuntu apache?

Read Now →

How to Increase Upload File Size Limit PHP in Ubuntu?

Read Now →

How to Upgrade Node.js Version in Ubuntu?

Read Now →

How to Enable Rewrite Mode for Apache in Ubuntu?

Read Now →

Connection for controluser as defined in your configuration failed - Ubuntu phpmyadmin Resolve?

Read Now →