Order allow,deny
Allow from all
authname "Authenticate yourself" ——Browser prompts for opening the url
authtype basic
authuserfile /etc/httpd/userpasswd --User & password file location
require valid-user
# htpasswd -c /etc/httpd/userpasswd frank --Create a user allowed to access
# htpasswd /etc/httpd/userpasswd george - -Create another one, remember the '-c' parameter, which is to create the password file and can only be used when creating the first user.
Note: If a directory uses password-controlled access, the directory will not be visible when its parent directory is listed through a web browser; that is, the directory will be hidden. But it can be accessed by directly entering the url (even if you have an account and password).
4. Domain name-based virtual host
NameVirtualHost *:80 --Add this configuration to set port 80 as the virtual host port
--The first virtual host
ServerName www.george.com
DocumentRoot /var/www/html/
.............
< /Directory>
--The second virtual host
ServerName mail.george .com
DocumentRoot /var/www/cgi-bin/openwebmail/
ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl
< ;Location />
......................
If the SeverName parameter of this experiment is connected to the IP address, we can also make an IP-based virtual host
5. Log parameters
ErrorLog logs/error_log --The storage location of the error log
LogLevel warn --Define the error log level, include: debug, info, notice, warn, error, crit, alert, emerg.
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User- Agent}i\"" combined
............
LogFormat "%{User-agent}i" agent --The four items areDefault format of access log
CustomLog logs/access_log combined --Use combined access log format
%h –Client’s ip address or host name
%l –The This is the RFC 1413 identity determined by the client's identd. The "-" symbol in the output indicates that the information here is invalid.
%u – The name of the client who accessed the webpage obtained by the HTTP authentication system. It is only valid if there is authentication. The "-" symbol in the output indicates that the information here is invalid.
%t – The time when the server completed processing the request.
"%r" – The quotation marks are the content of the request sent by the customer that contains a lot of useful information.
%>s – This is the status code returned by the server to the client.
%b – The last item is the number of bytes returned to the client excluding response headers.
"%{Referer}i" – This item indicates which web page the request was submitted from.
"%{User-Agent}i" – This item is the browser identification information provided by the customer's browser.
6. SSL encryption configuration
# yum install -y mod_ssl --Install encryption module
# vim /etc/httpd/conf.d /ssl.conf
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
SSLCertificateFile /etc/pki/tls/certs/localhost.crt --配置公钥文件
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key --配置秘钥文件
SSLOptions +StdEnvVars
ServerName www.george.com
DocumentRoot /var/www/cgi-bin/openwebmail/
ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl
SSLOptions +StdEnvVars
Options Indexes
order deny,allow
Allow from all
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
6.1、自己配置证书
# mkdir /etc/pki/test/
# cd /etc/pki/test
# openssl genrsa -out /etc/pki/test/test.key 1024 --秘钥
# openssl req -new -key test.key -out test.csr
Country Name (2 letter code) [XX]:cn
State or Province Name (full name) []:guangDong
Locality Name (eg, city) [Default City]:Shenzhen
Organization Name (eg, company) [Default Company Ltd]:IT
Organizational Unit Name (eg, section) []:maintenance
Common Name (eg, your name or your server's hostname) []:www.george.com
Email Address []:root@mail.george.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:Azt
# openssl req -x509 -days 365 -key test.key -in test.csr -out test.crt --Public key
# ls --Then configure the following test.crt && test.key to /etc /httpd/conf.d/ssl.conf
test.crt test.csr test.key
6.2. Test the certificate you configured
But the certificate we created ourselves is recognized in the browser as untrusted; The certificate status is also "Because the CA root certificate is not in the "Trusted Root Certification Authority" store, it is not trusted. ”
We need to manually import the certificate (test.crt) we created ourselves in the browser to the "Trusted Root Certification Authority"&&"Trusted Publisher" ". Taking Google Chrome as the column, the steps are as follows:
Then, several more dialog boxes will pop up. We click "Next" - "Finish" - "Yes ". That's OK.
At this time, use a browser to open our website and check the status of the certificate "There is no problem with the certificate."