search
Homephp教程php手册Apache用户认证方法汇总 (转载)

apache

Apache用户认证方法汇总

一.基本的Apache用户认证方法:

若对某一目录下的文件如/home/ftp/pub需要做到用户认证,则在httpd.conf中加入下面的行

options indexes followsymlinks
allowoverride authconfig
order allow,deny
allow from all


用在目录/home/ftp/pub下放文件.htaccess,内容如下:
authname "shared files"
authtype basic
authuserfile /etc/.passwd
require valid-user

用随Apache来的程序htpasswd 生成文件/etc/.passwd,每行一个用户名:密码

只要能提供正确的用户名和密码对,就允许登录访问,这是针对任何地址来的请求都要求提供用户名和密码认证。

二.针对部分网段或地址要求认证。

若公司LAN所在网段为192.168.0.0/24,且有一防火墙专线接入Internet,内部网卡的地址为192.168.0.1/32,则现在希望所有通过拨本地163通过防火墙上的apache反向代理向LAN上的另一WWW服务器访问时需要认证,而本地LAN上的用户不需认证。可以在httpd.conf中放入:
〈Directory /home/ftp/pub>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
order deny,allow
deny from 192.168.0.1
〈/Directory>

且在/home/ftp/pub/.htaccess中放入:
AuthName "shared files"
AuthType Basic
AuthUserFile /etc/.passwd
require valid-user
satisfy any

三.对同一目录及其下的子目录有不同的权限,仅某些人可以存取一目录下的子目录。
如有一目录/home/ftp/pub/sales,有三个用户user1,user2,user3都需要用户名和密码进入/home/ftp/pub,但仅user1,user2能进入/home/ftp/pub/sales.则放下面的行到httpd.conf

〈Directory /home/ftp/pub>
Options Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
〈/Directory>

〈Directory /home/ftp/pub/sales>
Options Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
〈/Directory>

且看/home/ftp/pub/.htaccess为:
AuthName "shared files"
AuthType Basic
AuthUserFile /etc/.passwd
require valid-user

且看/home/ftp/pub/sales/.htaccess
AuthName "shared files"
AuthType Basic
AuthUserFile /etc/.passwd
AuthGroupFile /etc/.salesgroup
require group manager

且文件/etc/.passwd内容为:
user1:passwd1
user2:passwd2
user3:passwd3

且文件/etc/.salesgroup内容为:
manager: user1 user2



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Active Directory 用户和计算机丢失 [以 3 种方式修复]Active Directory 用户和计算机丢失 [以 3 种方式修复]Apr 20, 2023 pm 01:25 PM

ActiveDirectory用户和计算机(ADUC)丢失是许多WindowsPro用户报告的最令人沮丧的问题之一。ADUC是一个令人难以置信的MMC管理单元,它使管理员能够管理MicrosoftActiveDirectory。但是,由于某种原因,它在Windows服务器或Enterprise/Pro版本中缺失。让我们深入了解它丢失的原因以及我们如何修复它。Windows11是否有ActiveDirectory?ActiveDirectory是任何想要管理远程

nginx反向代理ftp服务器怎么搭建nginx反向代理ftp服务器怎么搭建May 17, 2023 am 09:31 AM

1.安装nginx2.安装vsftpd3.修改nginx的配置文件nginx.conf  3.1首行添加ftp的用户  userftpuser;  3.2配置相关路径  server{    listen80;  #nginx代理的端口    server_namelocalhost;  #ftp服务器的地址    location/images{      root/home/ftpuser;  #代理ftp服务器的文件夹的绝对路径    indexftpuser;    #设置欢迎页    

在Go语言中使用FTP:完整指南在Go语言中使用FTP:完整指南Jun 17, 2023 pm 06:31 PM

随着互联网的快速发展,文件传输协议(FTP)一直是一种重要的文件传送方式。在Go语言中,使用FTP传输文件可能是很多开发人员的需求。然而,也许很多人并不知道如何在Go语言中使用FTP。在本篇文章中,我们将探讨如何在Go语言中使用FTP,从连接FTP服务器到文件传输,以及如何处理错误和异常。创建FTP连接在Go语言中,我们可以使用标准的"net"包来连接FTP

linux下 ftp命令有哪些linux下 ftp命令有哪些Mar 21, 2023 am 09:59 AM

linux下ftp命令有:1、ftp命令;2、close命令;3、disconnect命令;4、open命令;5、user命令;6、account命令;7、bye命令;8、quit命令;9、help命令;10、rhelp命令;11、ascii命令;12、binary/bi命令;13、bell命令等。

PHP与FTP:在网站开发中实现多个部门的文件共享PHP与FTP:在网站开发中实现多个部门的文件共享Jul 28, 2023 pm 01:01 PM

PHP与FTP:在网站开发中实现多个部门的文件共享随着互联网的发展,越来越多的企业开始借助网站平台进行信息发布和业务推广。然而,随之而来的问题是如何实现多个部门之间的文件共享和协作。在这种情况下,PHP和FTP成为了最常用的解决方案之一。本文将介绍如何利用PHP和FTP在网站开发中实现多个部门的文件共享。一、FTP介绍FTP(FileTransferPr

Python怎么使用FTP上传文件Python怎么使用FTP上传文件Apr 29, 2023 am 09:49 AM

FTP简介FTP即文件传输协议(FileTransferProtocol),是用于在网络上进行文件传输的一种标准协议。FTP客户端可以将文件从本地上传到服务器或从服务器下载到本地。ftplib模块Python提供了一个标准库ftplib,用于在Python中实现FTP客户端的功能。使用ftplib,我们可以连接到FTP服务器,执行各种FTP操作,如上传和下载文件等。代码解释下面是一个使用Python通过FTP上传文件的示例代码:fromftplibimportFTPimportargparsed

如何通过PHP在FTP服务器上进行目录和文件的比较如何通过PHP在FTP服务器上进行目录和文件的比较Jul 28, 2023 pm 02:09 PM

如何通过PHP在FTP服务器上进行目录和文件的比较在web开发中,有时候我们需要比较本地文件与FTP服务器上的文件,以确保两者之间的一致性。PHP提供了一些函数和类来实现这个功能。本文将介绍如何使用PHP在FTP服务器上进行目录和文件的比较,并提供相关的代码示例。首先,我们需要连接到FTP服务器。PHP提供了ftp_connect()函数来建立与FTP服务器

linux ftp 530什么意思linux ftp 530什么意思Mar 14, 2023 am 10:16 AM

linux ftp530的意思是linux ftp登录报错530,其解决办法:1、​查看“cat /etc/shells”是否有你用户的主目录和登录shell,若是没有,则进行添加;2、查看“/var/log/secure”文件,重新设置密码过期时间即可。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.