Implementation of Web service authentication

Source: Internet
Author: User

When you log in to the site, we can implement user-based authentication, and of course, based on a single user and group, configuration is similar, testing this feature:

Get ready:

Centos6.3 virtual machine,IP address:172.16.100.3, has been configured Yum source and can surf the internet in order not to affect the effect, you can first shut down the firewall and SElinux

To start the test:

1. Install the necessary packages

Yum-y Install httpd

2. Simple configuration, and turn on this service

a) [[email protected] ~]# vim/etc/httpd/conf/httpd.conf

Search:/#ServerName

Add servername localhost:80

b) [[email protected] ~]# cd/var/www/html/

Edit a Web page file named index.html here to customize the content

c) [[email protected] ~]# service httpd start

3. Open the browser, Access 172.16.100.3, can access to the customized page content

4. Edit the configuration file and add the appropriate configuration

[Email protected] ~]# vim/etc/httpd/conf/httpd.conf

Modify and add the following in the <directory "/var/www/html" > section

AllowOverride authconfig

AuthType Basic

AuthName "Restricted Site ..."

AuthUserFile "/ETC/HTTPD/CONF/HTPASSWD"

Require Valid-user

5. Create two users and create an authenticated user file when creating the first user

[Email protected] ~]# htpasswd-c-m/etc/httpd/conf/htpasswd Hadoop

[Email protected] ~]# htpasswd-m/etc/httpd/conf/htpasswd fsy

6. Check the configuration file for syntax errors, if correct, restart

[Email protected] ~]# httpd-t

[Email protected] ~]# service httpd restart

7. In the browser test can

Test success!

Other ways to modify the configuration file:

Based on individual user authentication:

AllowOverride authconfig

AuthType Basic

AuthName "Custom "

AuthUserFile "/ETC/HTTPD/CONF/HTPASSWD"

Require User Username

Based on user group authentication:

AllowOverride authconfig

AuthType Basic

AuthName "Custom "

AuthUserFile "/ETC/HTTPD/CONF/HTPASSWD"

authuserfile "/etc/httpd/conf/htgroups "

Require Group Name

Edit the Htgroups file to add :

Group name User name (note that the user name is separated by a space)


This article is from the "10917734" blog, please be sure to keep this source http://10927734.blog.51cto.com/10917734/1844473

Implementation of Web service authentication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.