Apache error: _default_ virtualhost overlap on port 443

前端 未结 4 584
情书的邮戳
情书的邮戳 2020-12-23 10:59

I get this error when trying to start Apache.

_default_ virtualhost overlap on port 443

I\'m trying to set up SSL. Almost every

相关标签:
4条回答
  • 2020-12-23 11:56

    On a vanilla Apache2 install in CentOS, when you install mod_ssl it will automatically add a configuration file in:

    {apache_dir}/conf.d/ssl.conf
    

    This configuration file contains a default virtual host definition for port 443, named default:443. If you also have your own virtual host definition for 443 (i.e. in httpd.conf) then you will have a confict. Since the conf.d files are included first, they will win over yours.

    To solve the conflict you can either remove the virtual host definition from conf.d/ssl.conf or update it to your own settings.

    0 讨论(0)
  • 2020-12-23 12:00

    I ran into this problem because I had multiple wildcard entries for the same ports. You can easily check this by executing apache2ctl -S:

    # apache2ctl -S
    [Wed Oct 22 18:02:18 2014] [warn] _default_ VirtualHost overlap on port 30000, the first has precedence
    [Wed Oct 22 18:02:18 2014] [warn] _default_ VirtualHost overlap on port 20001, the first has precedence
    VirtualHost configuration:
    11.22.33.44:80       is a NameVirtualHost
             default server xxx.com (/etc/apache2/sites-enabled/xxx.com.conf:1)
             port 80 namevhost xxx.com (/etc/apache2/sites-enabled/xxx.com.conf:1)
             [...]
    11.22.33.44:443      is a NameVirtualHost
             default server yyy.com (/etc/apache2/sites-enabled/yyy.com.conf:37)
             port 443 namevhost yyy.com (/etc/apache2/sites-enabled/yyy.com.conf:37)
    wildcard NameVirtualHosts and _default_ servers:
    *:80                   hostname.com (/etc/apache2/sites-enabled/000-default:1)
    *:20001                hostname.com (/etc/apache2/sites-enabled/000-default:33)
    *:30000                hostname.com (/etc/apache2/sites-enabled/000-default:57)
    _default_:443          hostname.com (/etc/apache2/sites-enabled/default-ssl:2)
    *:20001                hostname.com (/etc/apache2/sites-enabled/default-ssl:163)
    *:30000                hostname.com (/etc/apache2/sites-enabled/default-ssl:178)
    Syntax OK
    

    Notice how at the beginning of the output are a couple of warning lines. These will indicate which ports are creating the problems (however you probably already knew that).

    Next, look at the end of the output and you can see exactly which files and lines the virtualhosts are defined that are creating the problem. In the above example, port 20001 is assigned both in /etc/apache2/sites-enabled/000-default on line 33 and /etc/apache2/sites-enabled/default-ssl on line 163. Likewise *:30000 is listed in 2 places. The solution (in my case) was simply to delete one of the entries.

    0 讨论(0)
  • 2020-12-23 12:01

    It is highly unlikely that adding NameVirtualHost *:443 is the right solution, because there are a limited number of situations in which it is possible to support name-based virtual hosts over SSL. Read this and this for some details (there may be better docs out there; these were just ones I found that discuss the issue in detail).

    If you're running a relatively stock Apache configuration, you probably have this somewhere:

    <VirtualHost _default_:443>
    

    Your best bet is to either:

    • Place your additional SSL configuration into this existing VirtualHost container, or
    • Comment out this entire VirtualHost block and create a new one. Don't forget to include all the relevant SSL options.
    0 讨论(0)
  • 2020-12-23 12:04

    To resolve the issue on a Debian/Ubuntu system modify the /etc/apache2/ports.conf settings file by adding NameVirtualHost *:443 to it. My ports.conf is the following at the moment:

    # /etc/apache/ports.conf
    # If you just change the port or add more ports here, you will likely also
    # have to change the VirtualHost statement in
    # /etc/apache2/sites-enabled/000-default
    # This is also true if you have upgraded from before 2.2.9-3 (i.e. from
    # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
    # README.Debian.gz
    
    NameVirtualHost *:80
    Listen 80
    
    <IfModule mod_ssl.c>
        # If you add NameVirtualHost *:443 here, you will also have to change
        # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
        # to <VirtualHost *:443>
        # Server Name Indication for SSL named virtual hosts is currently not
        # supported by MSIE on Windows XP.
    
        NameVirtualHost *:443
    
        Listen 443
    </IfModule>
    
    <IfModule mod_gnutls.c>
        NameVirtualHost *:443
        Listen 443
    </IfModule>
    

    Furthermore ensure that 'sites-available/default-ssl' is not enabled, type a2dissite default-ssl to disable the site. While you're at it type a2dissite by itself to get a list and see if there is any other site settings that you have enabled that might be mapping onto port 443.

    0 讨论(0)
提交回复
热议问题