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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
![Active Directory Users and Computers Missing [Fixed in 3 Ways]](https://img.php.cn/upload/article/000/465/014/168196830849131.png?x-oss-process=image/resize,m_fill,h_207,w_330)
Active Directory Users and Computers (ADUC) loss is one of the most frustrating issues reported by many Windows Pro users. ADUC is an incredible MMC snap-in that enables administrators to manage Microsoft Active Directory. However, for some reason it is missing in the Windows Server or Enterprise/Pro editions. Let’s take a closer look at why it’s missing and how we can fix it. Does Windows 11 have Active Directory? Active Directory is useful for anyone wanting to manage remote

1. Install nginx 2. Install vsftpd 3. Modify the nginx configuration file nginx.conf 3.1 Add the ftp user userftpuser in the first line; 3.2 Configure the relevant path server{ listen80; #nginx proxy port server_namelocalhost; #ftp server address location/images{root /home/ftpuser; #The absolute path of the folder of the proxy ftp server indexftpuser; #Set the welcome page

With the rapid development of the Internet, File Transfer Protocol (FTP) has always been an important file transfer method. In Go language, using FTP to transfer files may be a need of many developers. However, maybe many people don't know how to use FTP in Go language. In this article, we will explore how to use FTP in Go language, from connecting to FTP server to file transfer, and how to handle errors and exceptions. Create FTP connection In Go language, we can use the standard "net" package to connect to FTP

The ftp commands under Linux include: 1. ftp command; 2. close command; 3. disconnect command; 4. open command; 5. user command; 6. account command; 7. bye command; 8. quit command; 9. help command ;10. rhelp command; 11. ascii command; 12. binary/bi command; 13. bell command, etc.

PHP and FTP: Achieve file sharing among multiple departments in website development. With the development of the Internet, more and more companies are beginning to use website platforms for information release and business promotion. However, the problem that arises is how to achieve file sharing and collaboration among multiple departments. In this case, PHP and FTP become one of the most commonly used solutions. This article will introduce how to use PHP and FTP to achieve file sharing among multiple departments in website development. 1. Introduction to FTP FTP (FileTransferPr

Introduction to FTP FTP is File Transfer Protocol (FileTransferProtocol), which is a standard protocol for file transfer on the network. FTP client can upload files from local to server or download from server to local. The ftplib module Python provides a standard library ftplib for implementing FTP client functions in Python. Using ftplib, we can connect to the FTP server and perform various FTP operations, such as uploading and downloading files, etc. Code explanation The following is a sample code for uploading files through FTP using Python: fromftplibimportFTPimportargparsed

How to compare directories and files on an FTP server through PHP In web development, sometimes we need to compare local files with files on the FTP server to ensure consistency between the two. PHP provides some functions and classes to implement this functionality. This article will introduce how to use PHP to compare directories and files on an FTP server, and provide relevant code examples. First, we need to connect to the FTP server. PHP provides the ftp_connect() function to establish an FTP server

linux ftp530 means linux ftp login error 530. The solution is: 1. Check "cat /etc/shells" to see if your user's home directory and login shell are there. If not, add them; 2. Check "/var /log/secure" file and reset the password expiration time.
