Pet*_*tah 7 ssl https xampp virtualhost apache-2.2
我正在尝试像这样设置我的本地 Apache 配置:
http://localhost/ 应该服务 ~/
http://development.somedomain.co.nz/ 应该服务 ~/sites/development.somedomain.co.nz/
https://development.assldomain.co.nz/ 应该服务 ~/sites/development.assldomain.co.nz/
我只想允许来自我们本地网络(192.168.1.* 范围)和我自己(127.0.0.1)的连接。
我已经设置了我的主机文件:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 development.somedomain.co.nz
127.0.0.1 development.assldomain.co.nz
127.0.0.1 development.anunuseddomain.co.nz
Run Code Online (Sandbox Code Playgroud)
我的 Apache 配置如下所示:
Listen 80
NameVirtualHost *:80
<VirtualHost development.somedomain.co.nz:80>
ServerName development.somedomain.co.nz
DocumentRoot "~/sites/development.somedomain.co.nz"
DirectoryIndex index.php
<Directory ~/sites/development.somedomain.co.nz>
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost localhost:80>
DocumentRoot "~/"
ServerName localhost
<Directory "~/">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
Listen *:443
NameVirtualHost *:443
AcceptMutex flock
<VirtualHost development.assldomain.co.nz:443>
ServerName development.assldomain.co.nz
DocumentRoot "~/sites/development.assldomain.co.nz"
DirectoryIndex index.php
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /Applications/XAMPP/etc/ssl.crt/server.crt
SSLCertificateKeyFile /Applications/XAMPP/etc/ssl.key/server.key
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
<Directory ~/sites/development.assldomain.co.nz>
SSLRequireSSL
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
</IfModule>
Run Code Online (Sandbox Code Playgroud)
http://development.somedomain.co.nz/ http://localhost/并且https://development.assldomain.co.nz/工作正常。
问题是当我请求http://development.anunuseddomain.co.nz/或http://development.assldomain.co.nz/它响应与http://development.somedomain.co.nz/
我希望它拒绝所有与虚拟主机服务器名称不匹配的请求以及所有使用 http 请求的 https 主机请求
PS 我在 Mac OS X 10.5.8 上运行 XAMPP
小智 7
基于 SSL 的虚拟主机不支持命名虚拟主机。
问题源于服务器名称也在 SSL 请求中加密的事实。因此,当服务器收到对“某个域名”或其他内容的请求时,它将默认为不在443 上的命名 VHost 。
解决方案:
更正:
# Listen :80
Listen *:80
# Listen on IP Address for :443
Listen 127.0.0.1:443
<VirtualHost development.somedomain.co.nz:80>
ServerName development.somedomain.co.nz
DocumentRoot "~/sites/development.somedomain.co.nz"
DirectoryIndex index.php
# Stay consistent with your syntax definitions. This and the 443 Vhost Directory
# were not Quoted. That's not to say it makes a difference guaranteed,
# but it's always a good habit.
<Directory "~/sites/development.somedomain.co.nz">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "~/"
<Directory "~/">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
# Does this need to exist outside of the VHost Definition ??
AcceptMutex flock
<VirtualHost 127.0.0.1:443>
ServerName development.assldomain.co.nz
DocumentRoot "~/sites/development.assldomain.co.nz"
DirectoryIndex index.php
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /Applications/XAMPP/etc/ssl.crt/server.crt
SSLCertificateKeyFile /Applications/XAMPP/etc/ssl.key/server.key
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
<Directory "~/sites/development.assldomain.co.nz">
SSLRequireSSL
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
</IfModule>
Run Code Online (Sandbox Code Playgroud)
小智 2
当 apache 无法 macch vhost 时,它会打开默认的虚拟主机。总是有一个默认值,如果没有明确定义,它就是配置文件中的第一个虚拟主机定义。
您可以使用 httpd -S 检查默认虚拟主机是什么
如果您愿意,您可以定义默认值并禁止访问它,如 defraagh 指出的那样
| 归档时间: |
|
| 查看次数: |
7790 次 |
| 最近记录: |