Questões do host virtual

0

Eu tenho um servidor ubuntu hospedado no Linode com muitos sites no diretório / var / www .

Eu tenho dois domínios registrados ( preplogs.com, icerge.com e um monte de outros sites que eu acesso via 8.8.8.8/domain ) cada um deles aponta para sub-diretórios no / var / www .

Meu problema é que minhas definições de hosts virtuais não estão respondendo como pretendo.

Eu tenho o host padrão 000-default.conf com o seguinte:

<VirtualHost *:80>
        # 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 www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www

        LimitRequestFieldSize 100000

        # 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>

O segundo vhost é chamado icerge.conf :

<VirtualHost *:80>
        # 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 www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/icerge

        LimitRequestFieldSize 100000

        # 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>

E o terceiro domínio é chamado preplogs.com :

<VirtualHost *:80>
        # 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 www.preplogs.com
        ServerAlias preplogs.com
        ServerAlias www.preplog.com
        ServerAlias preplog.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/DrupalQuiz

        LimitRequestFieldSize 100000

        # 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>

Meu problema é que eu não entendo o site certo quando visito diferentes endereços.

Quando visito o endereço IP, espero ver o "índice de" listagens de todos os domínios no servidor, mas vejo o site pré-requisitos .

O Preplogs.com carrega o site dos preplogs conforme o esperado.

icerge.com carrega as listagens 'index of' do servidor.

Alguém pode ajudar? Não tenho certeza de como desvendar essa bagunça.

    
por sisko 14.11.2017 / 13:09

1 resposta

0

Você não configurou as ServerName e ServerAlias nas duas primeiras configurações de vhost.

  1. Configure um vhost padrão, que manipulará casos de endereço IP usado ou semelhante. Deixe o ServerName em branco para este.
  2. Configure um vhost para cada um dos seus sites. Estes devem conter ServerName e possível ServerAlias .

Você provavelmente deseja definir o campo ServerAdmin também, pois isso é usado em páginas de erro, como um ponto de contato.

    
por vidarlo 14.11.2017 / 13:18