所以我想在一台服务器上这一切:
- 3 domains / websites - SSL on one of them - nothing to be accessed by an IP address (eg 'domain.com' is okay, but not by just typing '123.55.44.123' into the browser)
我在用:
- Ubuntu 12.04 LTS - Apache
我已经设置了这些虚拟主机,一切都非常适合非SSL
<VirtualHost *:80> ServerName 123.55.33.123 DocumentRoot /var/www/random-empty-folder <Directory /> Options FollowSymLinks Deny from all # notice the deny here </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.domain-one.com ServerAlias domain-one.com *.domain-one.com DocumentRoot /var/www/domain-one <Directory /> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost> <VirtualHost *:80> ServerName www.domain-two.com ServerAlias domain-two.com *.domain-two.com DocumentRoot /var/www/domain-two <Directory /> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost> ...etc. for 'domain-three'
问题是,我不能得到这个SSLconfiguration。 我的标准SSL设置是这样的,但允许使用IP地址访问。 我只需要停止:
<VirtualHost *:443> ServerName www.domain-two.com:443 ServerAlias domain-two.com *.domain-two.com DocumentRoot /var/www/domain-two SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key <Directory /> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost>
还有一个'default-ssl'网站/文件被禁用,所以不知道我是否应该做些什么。 我试过启用它并进行更改,但大多数情况下我遇到了“ 默认重复”错误。
所以,基于上面的设置,我只需要阻止访问[https]://123.55.44.123。 提前致谢。
我做任何修改后,总是运行“服务apache2重新加载”,以防万一有人想知道。
由于所请求的域名在http头中(因此在apache必须决定使用哪个vhostconfiguration时仍然是encryption的),apache使用IP和端口来select使用哪个SSL vhostconfiguration,而不是域名。
编辑:
在我的回答中,我应该提到SNI和其他一些因素。 SNI是对TLS的补充,允许服务器在一个IP /端口组合上使用多个命名的虚拟主机configuration。 但是因为你只有一个*:443的VirtualHostconfiguration块,Apache总是会select它。
你想要做什么是可能的,最简单的方法就是激活default-ssl作为不针对特定域的请求的一个catchall。 在激活default-ssl时,我不太清楚“默认重复”错误是什么意思,完整的错误信息可能会更有帮助。 我可以build议命名符号链接000-default-ssl,这样你的任何选项都会首先被设置。
一个可能的select,而不是阻止访问,如果你转发到你的主机名到IP地址的任何请求? 这可以用htaccess或mod_rewrite来完成。
RewriteEngine On RewriteCond %{HTTP_HOST} ^123\.55\.33\.123 RewriteRule (.*) http://domain-one.com/$1 [R=301,L]
我相信,因为SSL的工作方式(IP地址相关),你将无法阻止在Apache级别的请求。 如果你正在使用PHP等,你可以有一个包含文件,检查$ _SERVER ['HTTP_HOST'],如果它是你的IP地址就会死掉。