Authentication is any process by which you verify that someone is who they claim they are. Authorization is any process by which someone is allowed to be where they want to go or to have information that they want to have.
I will show here how to set up basic auth on the apache with windows.
Pre-requests
Windows VPSApache server ( That's it )
( In windows it might be difficult to setup the Apache alone. So instead use something ling xampp, wamp or laragon.)
RestClient
( I personally use the postman, but you can use your preferable client)
Steps
- Enable the necessary modules in the Apache
- Create the password file
- Set the auth directives in the virtual host file.
- Verify basic auth.
Enable the necessary modules in the Apache
Open the httpd.conf file in the apache's conf folder.httpd.conf file |
Enable the necessary modules to make the basic auth working.
Necessary modules
- mod_auth_basic
- mod_authn_file
Enable the necessary modules |
Restart the apache to make the modules active.
Create Password File
You need to create a password file before you can use it for the basic auth. To create a password file you have to use the htpasswd.exe( it comes with the apache itself. You can find it inside the bin folder of the Apache server )
htpasswd.exe to create password file |
Create a password using the htpasswd.exe
create basic auth password file |
verify that file has actually created.
the password file |
Set the auth directives in the virtual host file
<VirtualHost *:80>
ServerName xx.xx.xxx.xxx
ServerAlias alias
<location / >
AuthType Basic
AuthName "Restricted Routes"
# (Following line optional)
AuthBasicProvider file
AuthUserFile "C:\auth\passwords"
Require user mansih
</location>
</VirtualHost>
Set the location to the URL you want to enable the basic auth on.
For example, if you want to secure the /login with basic auth then replace <location /> to <location /login>
To read more about location click here. Apache location
After updating the virtual host file reload the apache to make the basic auth working.
Verify basic auth.
I am using the postman to verify the basic auth.
In case of valid username and password, you will get the 200 HTTP response.
postman 200 HTTP response |
In case of invalid username and/or password, you will get the 200 HTTP response.
postman 401 HTTP response |
Hope you find it useful.
Have a nice Day !
Marvelous, Very useful post, Thank You for the information, Keep it up.
ReplyDeleteAbhishek Rawat
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThank you for sharing information.It was very useful.
ReplyDeleteWell done
HI,
ReplyDeleteYou have written very good informative information about latest topic. You have given great information article that will be very useful for me. I want to know more information deeply about it.
Thanks for taking the time to talk about this, I feel strongly about it and really like mastering more on this subject. If feasible, as you acquire experience, would you mind updating your blog with much more information and facts? It is very helpful for me.
ReplyDeleteThank You for the information, Keep it up.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteGreat post. Keep writing such kind of info on your page. Will used it up for my site SBObet :)
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.
ReplyDeletehotmail.com
thanks for sharing informative information.
ReplyDeletei find this article is very useful for me atleast.
ReplyDeletedesert safari dubai
ReplyDeleteI’ve been thinking about writing a very comparable post over the last couple of weeks, I’ll probably keep it short and sweet and link to this instead if that's cool. Thanks
Staten Island Ferry
Very engaging post keep posting more.
ReplyDeleteBeautiful article will keep visiting this site for more blogs. thank you
Great post, keep sharing your post so that it may inspire more people. Thank you.
FivoTech is one of the fastest growing SEO agency in Chennai, We provide the complete solution of digital marketing.
Where we help to rank your website and give the best ROI.
thanks for your time to write up this very article about seo
ReplyDeleteYour post is very unique and reliable information for all readers to write more on the same topic and share with us your info...Thanks, Slide Business
ReplyDeleteYour post is very unique and reliable information for all readers to write more on the same topic and share with us your info...Thanks, Slide Business
ReplyDeleteThanks for sharing this informative information with us. It is a well-written article in simple words I like it. For more info about website redesign company and the best web development company in india then just visit.
ReplyDeleteIts been a great thing that were are witnessing right now.
ReplyDeleteBrother Printer Sleep Mode Off
Thanks for sharing such an amazing blog with us I really like to read such type of article.
ReplyDeleteDomain & web hosting
Thanks for sharing nice information with us. I like your post and share your post with my friends. Keep sharing. AOL mail
ReplyDeleteGreat and amazing blog thanks for sharing
ReplyDeleteWho Invented Yoga Pants
Very great blog
ReplyDeleteFood Beginning With Z
Very well and great blog thanks admin for sharing such a great and super blog
ReplyDeleteHow Tall Are Bears
Thanks for the share, truly amazing. Also, check this out if you are looking for professional website or logo design services:
ReplyDeleteBuy Logo
This is truly amazing, thanks for the share. Also, check this out if you are looking for professional website or logo design services:
ReplyDeleteBuy Logo
If you are looking for remote shelter and embarking on an adventurous evening out,creek park dubai is not the right place for you. Visitors can enjoy many outdoor activities that will entice anyone and keep them away from their busy and monotonous schedule.
ReplyDeletecreek park dubai is the second largest park in Dubai, with endless acres of meadows, children's playgrounds and gardens.
In 1994, creek park dubai opened and is one of the oldest and largest parks in Dubai. The park is bordered by a saltwater spring.
Being somebody who anticipates praising the New Year 2021 with their loved ones, you need to wish them well. Through our correspondence, people are understood what you can use to build up cheerful relations with individuals. Thus, on New Year's Eve, we present to you some beautiful New Year Wishes for companions, family, spouse, sweetheart, and other new year wishes good tidings.
ReplyDeleteNew Year Resolution