Apache2的怪异重定向。 (默认的站点覆盖等) [英] Apache2 weird redirection. (Default site overriding others)

查看:160
本文介绍了Apache2的怪异重定向。 (默认的站点覆盖等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚从亚马逊EC2移动到另一个VPS,他们两个运行Ubuntu 12.04。
但现在我得到一些很奇怪的重定向。

不管我使用HTTP访问(端口80)我结束了在同一个域的域的名称。我没有重定向到该域。

http://domain1.com 工作正常,但的 http://domain2.com 重定向到 http://domain1.com
即使我刚刚进入IP-ADRESS,我得到domain1.com。这似乎Apache2的无法解析请求是来自什么名字。

如果我在 https://domain2.com 访问通过SSL,它加载只是没有重定向罚款。

我想我删除了已启用的站点 - -folder的default.conf文件刚刚安装的Apache2后。可这有什么影响?

下面是 apache2ctl -S 输出:

  AH00548:拥有了NameVirtualHost没有效果,将在下一版本/etc/apache2/ports.conf:5被删除
AH00558:apache2的:无法可靠地确定了服务器的完全合格的域名,使用127.0.0.1。全局配置服务器名称指令燮preSS此消息
虚拟主机配置:
*:80是了NameVirtualHost
         默认的服务器domain1.com(/etc/apache2/sites-enabled/domain1.com.conf:1)
         80端口namevhost domain1.com(/etc/apache2/sites-enabled/domain1.com.conf:1)
         80端口namevhost domain2.com(/etc/apache2/sites-enabled/domain2.com.conf:1)
                 别名www.domain2.com
*:443是一个了NameVirtualHost
         默认的服务器domain1.com(/etc/apache2/sites-enabled/domain1.com.conf:10)
         端口443 namevhost domain1.com(/etc/apache2/sites-enabled/domain1.com.conf:10)
         端口443 namevhost domain2.com(/etc/apache2/sites-enabled/domain2.com.conf:9)
                 别名www.domain2.com
         端口443 namevhost domain3.com(/etc/apache2/sites-enabled/domain3.com.conf:2)
                 别名www.domain3.com
ServerRoot的:在/ etc / apache2的
主要的DocumentRoot:在/ var / www的
主要错误日志:/var/log/apache2/error.log
互斥SSL缓存:using_defaults
互斥默认:DIR =在/ var /锁/ Apache2的机制=的fcntl
互斥MPM-接受:using_defaults
互斥看门狗回调:using_defaults
互斥重写地图:using_defaults
互斥SSL装订:using_defaults
PIDFILE:/var/run/apache2/apache2.pid
定义:DUMP_VHOSTS
定义:DUMP_RUN_CFG
用户:NAME =WWW的数据ID = 33 NOT_USED
组:NAME =WWW的数据ID = 33 NOT_USED

这是我domain1.com.conf(完全类似除了域名domain2.com.conf):

 <虚拟主机*:80>    服务器名称domain1.com
    的ServerAdmin my@email.com
    DocumentRoot的/var/www/domain1.com< /虚拟主机>< IfModule mod_ssl.c>
<虚拟主机*:443>
    #ServerName指令设置请求方案,主机名和端口
    #服务器用来标识自己。这是在创建时使用
    #重定向URL。在虚拟主机的情况下,服务器名
    #指定了主机名必须出现在请求的Host:头
    #匹配这个虚拟主机。对于默认的虚拟主机(本文件)此
    因为它是无论使用作为最后的手段主机#值不是决定性的。
    #但是,你必须将其设置为任何其他虚拟主机明确。    服务器名称domain1.com    站长的ServerAdmin @本地
    DocumentRoot的/var/www/domain1.com    在SSLEngine的
    了SSLCertificateFile /etc/apache2/ssl/domain1.com/domain1.com.crt
    了SSLCertificateKeyFile /etc/apache2/ssl/domain1.com/domain1.com.key
    SSLCertificateChainFile /etc/apache2/ssl/domain1.com/sub.class1.server.ca.pem    #为SSL安全设置
    SSLProtocol ALL -SSLv2 -SSLv3
    SSLHonorCipherOrder在
    的SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS    #可用记录等级:trace8,...,TRACE1,调试,信息,通知,警告,
    #错误,暴击,机警,EMERG。
    #它也可以配置为特定的日志级别
    #模块,例如
    #LogLevel信息SSL:警告    错误日志$ {} APACHE_LOG_DIR /error.log
    的CustomLog $ {} APACHE_LOG_DIR结合/access.log    #对于来自CONF可用/,这是大多数配置文件
    #在全球范围内启用或禁用,有可能
    #仅包括一个特定的虚拟主机的线路。例如
    #以下行启用此主机的CGI配置只
    之后#已与a2disconf在全球范围禁用。
    #INCLUDE CONF可用/服务-CGI-bin.conf
< /虚拟主机>
< / IfModule>
#VIM:语法=阿帕奇TS = 4 SW = 4 STS = 4 SR NOET


解决方案

该default.conf在/ etc /阿帕奇/站点可用的不是特别的 - 但是当它列为在/ etc /阿帕奇/网站的第一个文件 - 启用(通常为00-default.conf,所以它是第一个在列表中),那么这将是默认的。如果不存在,那么任何其他(如domain1.conf)列为第一是那么如果网址不被任何在其他文件中列出的其他虚拟主机的抓将要显示的默认站点。

I have just moved from Amazon EC2 to another VPS, running Ubuntu 12.04 on both of them. But now I get some very strange redirections.

No matter which domain name I access using http (port 80) I end up on the same domain. I have no redirections to this domain.

http://domain1.com works fine, but http://domain2.com redirects to http://domain1.com Even if I just enter the IP-adress, I get domain1.com. It seems Apache2 can't resolve what name the request is coming from.

If I access over SSL at https://domain2.com, it loads just fine with no redirection.

I think I deleted the "default.conf" file in the "sites-enabled"-folder just after installing apache2. Can this have any influence?

Here is the apache2ctl -S output:

AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/ports.conf:5
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:1)
         port 80 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:1)
         port 80 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:1)
                 alias www.domain2.com
*:443                  is a NameVirtualHost
         default server domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:10)
         port 443 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:10)
         port 443 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:9)
                 alias www.domain2.com
         port 443 namevhost domain3.com (/etc/apache2/sites-enabled/domain3.com.conf:2)
                 alias www.domain3.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

And this is my domain1.com.conf (completely similar to domain2.com.conf except for the domain names):

<VirtualHost *:80>

    ServerName domain1.com
    ServerAdmin my@email.com
    DocumentRoot /var/www/domain1.com

</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.

    ServerName domain1.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/domain1.com

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/domain1.com/domain1.com.crt
    SSLCertificateKeyFile /etc/apache2/ssl/domain1.com/domain1.com.key
    SSLCertificateChainFile /etc/apache2/ssl/domain1.com/sub.class1.server.ca.pem

    # Security settings for SSL
    SSLProtocol ALL -SSLv2 -SSLv3
    SSLHonorCipherOrder On
    SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

解决方案

The default.conf in /etc/apache/sites-available isn't special - but when it's listed as the first file in /etc/apache/sites-enabled (usually as 00-default.conf, so it is first in the list) then it will be the default. If that isn't there, then whatever else (like domain1.conf) is listed first is then the default site that will be shown if the URL isn't caught by any of the other vhosts listed in the other files.

这篇关于Apache2的怪异重定向。 (默认的站点覆盖等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆