Apache Reverse Proxy with Authentication Example
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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Install Yarn npm in Ubuntu?
- How to Upgrade PHP Version from 7.3 to 7.4 in Ubuntu?
- How to Upgrade PHP Version from 7.2 to 7.3 in Ubuntu?
- How to Enable Apache mod_rewrite Module in Ubuntu?
- Laravel 8 PayPal Integration Tutorial
- How to create quick apache virtual host in Ubuntu?
- How to create virtual host in ubuntu apache?
- How to Increase Upload File Size Limit PHP in Ubuntu?
- How to Upgrade Node.js Version in Ubuntu?
- How to Enable Rewrite Mode for Apache in Ubuntu?
- Connection for controluser as defined in your configuration failed - Ubuntu phpmyadmin Resolve?