Apache 如何为sub-domain.domain.com配置客户端授权?
我为特定子文件夹生成了具有客户端身份验证的wamp服务器: 现在,我想访问我的站点,而不是Apache 如何为sub-domain.domain.com配置客户端授权?,apache,wamp,Apache,Wamp,我为特定子文件夹生成了具有客户端身份验证的wamp服务器: 现在,我想访问我的站点,而不是https://www.domain.com/subdomain/app1使用https://app1.domain.com <VirtualHost *:80> ServerName www.domain.com ServerAlias *.domain.com VirtualDocumentRoot "C:\wamp\www\demo\%1" ErrorLog
https://www.domain.com/subdomain/app1
使用https://app1.domain.com
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias *.domain.com
VirtualDocumentRoot "C:\wamp\www\demo\%1"
ErrorLog "logs\errors.log"
<directory "C:\wamp\www\demo\%1">
Options FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
</VirtualHost>
<LocationMatch ^(?=.*/subomain/app1//)(?!.*/subomain/app1//service).*>
#SSLOptions +StdEnvVars +ExportCertData
SSLRequire %{SSL_CLIENT_S_DN_CN} eq "Shob"
</LocationMatch>
当我尝试访问url时,会被要求选择客户端证书,但当我选择匹配的证书时,会出现错误403禁止
当我使用OpenSSL生成证书时,我使用了*.domain.com
作为服务器密钥的CN
这是我在httpd-ssl.conf中的虚拟主机定义
<VirtualHost *:443>
ServerName www.domain.com:443
DocumentRoot "c:/wamp/www"
ServerAdmin admin@domain.com
ErrorLog "C:/wamp/bin/apache/apache2.4.9/logs/ssl_error.log"
TransferLog "C:/wamp/bin/apache/apache2.4.9/logs/ssl_access.log"
SSLEngine on
SSLVerifyClient require
SSLVerifyDepth 10
SSLCertificateFile "C:\wamp\bin\apache\apache2.4.9\conf\cert\server.cer"
SSLCertificateKeyFile "C:\wamp\bin\apache\apache2.4.9\conf\cert\server.key"
SSLCACertificateFile "C:\wamp\bin\apache\apache2.4.9\conf\cert\ca.cer"
<LocationMatch ^(?=.*/subomain/app1/)(?!.*/subdomain/app1/service).*>
SSLRequire %{SSL_CLIENT_S_DN_CN} eq "App1Key"
</LocationMatch>
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
BrowserMatch "MSIE [2-5]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
CustomLog "c:/wamp/bin/apache/apache2.4.9/logs/ssl_request.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
更新
我已根据答案将以下代码添加到ssl.conf中,但现在客户端证书始终有效,并且它忽略了LocationMatch
<directory "C:\wamp\www\demo\%1">
Options FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from all
</directory>
并不是您的SSL设置禁止403 将此项添加到
块的末尾(就在
之前,尽管最好将其放在那里),以授予访问虚拟主机的DocumentRoot
文件夹的权限:
<Directory "c:/wamp/www">
Order allow, deny
Allow from all
</Directory>
命令允许,拒绝
通融
或者,如果您使用的是Apache 2.4或更高版本:
<Directory "c:/wamp/www">
Require all granted
</Directory>
要求所有授权
您还应该检查在上一次设置时,在上一次
块中是否还有其他内容,并将其带进来。例如,您可能需要AllowOverride
或设置一些选项
,但上述操作将解决您所问的问题。您好,谢谢您的回答,我已更新了我的问题并添加了不同的目录,现在网站已加载,但问题是它忽略了位置匹配条件“SSLRequire%{SSL_CLIENT_S_DN_CN}eq'something'”我希望它能正常工作您的位置匹配中有两个错误,“submain”而不是“subdomain”,两个正斜杠而不是“service”之前的一个.但事实上,我解决了你原来的问题,所以我的答案被接受是公平的。我会尽力帮助你解决接下来的问题,或者你可以发布另一个问题,这确实是。实际上,第三个错误,在第一部分中的“app1”之后也出现了双正斜杠。解决这些问题有望解决问题。