2017-05-17 23 views
0

많은 질문/답변이 있지만 내 문제를 해결하지 못했습니다.Apache2 - 항상 기본 VHOST를 제공합니다.

내 설정 : - 동일한 IP (가상 컴퓨터의 IP, 다른 곳의 IP)로 프록시 리디렉션하도록 구성된 2 개의 하위 도메인 (sub1.test.de 및 sub2.test.de)이 있습니다.) - 내 가상 호스트 에 대한 두 개의 구성 파일을 가지고 - 가상 머신 대신 별도의 것들 중 하나 개의 설정 파일에 모든 가상 호스트를 가하고, 우분투 14.04

내가 NameVirtualHost *:80 설정을 시도

를 실행, ports.conf 내부 NameVirtualHost *:80을 설정하고 대신 IP를 지정 와일드 카드이지만 행운이 없습니다. sub2.test.de을 열면 여전히 sub1.test.de으로 리디렉션됩니다.

이 내 sub1.test.de.conf :

<VirtualHost *:80> 
    ServerName sub1.test.de 

    ServerAdmin [email protected] 
    DocumentRoot /var/www/sub1.test.de/html 

    # 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 

    ErrorLog /var/www/sub1.test.de/log/error.log 
    CustomLog /var/www/sub1.test.de/log/access.log combined 

    # Wildfly api Prox Bypass 
    ProxyPass /api http://someip:8080/api 
    ProxyPassReverse /api http://someip:8080/api 

    # Websocket Proxy Bypass 
    RewriteEngine on 
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC] 
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC] 
    RewriteRule .* ws://sub1.test.de:9000%{REQUEST_URI} [P] 

    ProxyPass /socket http://someip:9000/socket 
    ProxyPassReverse /socket http://someip:9000/socket 

    <Directory /var/www/sub1.test.de/html> 

     # Enable rewriting 
     RewriteEngine On 

     # If its not HTTPS 
     # RewriteCond %{HTTPS} off 

     # Comment out the RewriteCond above, and uncomment the RewriteCond below if you're using a load balancer (e.g. CloudFlare) for SSL 
     # RewriteCond %{HTTP:X-Forwarded-Proto} !https 

     # Redirect to the same URL with https://, ignoring all further rules if this one is in effect 
     #RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R,L] 

     # If we get to here, it means we are on https:// 

     # If the file with the specified name in the browser doesn't exist 
     RewriteCond %{REQUEST_FILENAME} !-f 

     # and the directory with the specified name in the browser doesn't exist 
     RewriteCond %{REQUEST_FILENAME} !-d 

     # and we are not opening the root already (otherwise we get a redirect loop) 
     RewriteCond %{REQUEST_FILENAME} !\/$ 

     # Rewrite all requests to the root 
     RewriteRule ^(.*)/

    </Directory> 
이 내 sub1.test.de.conf입니다 :

<VirtualHost *:80> 
    ServerName sub2.test.de 

    ServerAdmin [email protected] 
    DocumentRoot /var/www/sub2.test.de/html 


    # 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 

    ErrorLog /var/www/sub2.test.de/log/error.log 
    CustomLog /var/www/sub2.test.de/log/access.log combined 

    # Wildfly api Prox Bypass 
    ProxyPass /api http://someip:8080/api 
    ProxyPassReverse /api http://someip:8080/api 

    <Directory /var/www/sub2.test.de/html> 

     # Enable rewriting 
     RewriteEngine On 

     # If its not HTTPS 
     # RewriteCond %{HTTPS} off 

     # Comment out the RewriteCond above, and uncomment the RewriteCond below if you're using a load balancer (e.g. CloudFlare) for SSL 
     # RewriteCond %{HTTP:X-Forwarded-Proto} !https 

     # Redirect to the same URL with https://, ignoring all further rules if this one is in effect 
     #RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R,L] 

     # If we get to here, it means we are on https:// 

     # If the file with the specified name in the browser doesn't exist 
     RewriteCond %{REQUEST_FILENAME} !-f 

     # and the directory with the specified name in the browser doesn't exist 
     RewriteCond %{REQUEST_FILENAME} !-d 

     # and we are not opening the root already (otherwise we get a redirect loop) 
     RewriteCond %{REQUEST_FILENAME} !\/$ 

     # Rewrite all requests to the root 
     RewriteRule ^(.*)/

    </Directory> 

여전히
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 2a01:4f8:c0c:365::2. Set the 'ServerName' directive globally to suppress this message 

VirtualHost configuration: 

*:80     is a NameVirtualHost 
     default server sub1.test.de (/etc/apache2/sites-enabled/sub1.test.conf:3) 
     port 80 namevhost sub1.test.de (/etc/apache2/sites-enabled/sub1.test.de.conf:3) 
     port 80 namevhost sub2.test.de (/etc/apache2/sites-enabled/sub2.test.de.conf:1) 

, 개방 sub2.test.de 항상 나 sub1.test.de에 : apachectl -t -D DUMP_VHOSTS나에게 다음과 같은 출력을 제공합니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

답변

0

해결했습니다. 문제는 A-NAME 레코드가 아닌 내 도메인이 나열된 정규 리디렉션 항목이 있다는 것입니다. 리디렉션을 A-NAME 레코드로 변경하고 DNS 새로 고침을 위해 몇 시간을 기다린 후 모든 것이 정상적으로 작동했습니다.