Serwer Apache2, konfiguracja dwóch wirtualnych hostów

Konfiguracja serwerów, usług, itp.
mtbakk
Posty: 7
Rejestracja: 02 lutego 2012, 12:37

Serwer Apache2, konfiguracja dwóch wirtualnych hostów

Post autor: mtbakk »

Witam.

Mam skonfigurowany serwer apache2 i SSL na Debianie Squeeze. Wygenerowałem sobie tylko jeden certyfikat, który nie zawiera Common Name. Mam stworzone wirtualne hosty w sites-available i aktywowane w site-enabled: default, default-ssl, domena1.pl, domena1.pl-ssl

W domyślnych ustawieniach wirtualnych hostów i default-ssl nie mam podanych opcji ,,ServerName'' i ,,ServerAlias'' jest tylko opcja ,,ServerAdmin'', a w wirtualnych hostach:

Kod: Zaznacz cały

domena1.pl i domena1.pl-ssl mam podane:
ServerName [url=http://www.domena1.pl]www.domena1.pl[/URL]
ServerAlias domena1.pl
ServerAdmin [EMAIL="webmaster@domena1.pl"]webmaster@domena1.pl[/EMAIL]
Problem polega na tym, że jak wchodzę przez HTTPS i adres ip serwera to zamiast załadować mi się wirtualny host default-ssl, ładuje mi się wirtualny host domena1.pl-ssl. Jak wchodzę normalnie przez HTTP to wszystko jest w porządku.

Orientujecie się może ktoś w czym może tkwić problem?
mariaczi
Member
Posty: 1343
Rejestracja: 08 lutego 2008, 12:58
Lokalizacja: localhost@śląskie

Post autor: mariaczi »

mtbakk pisze:Orientujecie się może ktoś w czym może tkwić problem?
Tak, w konfiguracji ;)
Podaj dokładnie jak masz skonfigurowane te wirtualne serwery. Na podstawie tego co podałeś to tylko wróżka wskaże błąd.
mtbakk
Posty: 7
Rejestracja: 02 lutego 2012, 12:37

Post autor: mtbakk »

Już podaję.

Kod: Zaznacz cały

ls -l -a /etc/apache2/mods-enabled

lrwxrwxrwx 1 root root   28 12-14 13:08 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root   28 12-14 13:08 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root   33 12-14 13:08 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root   33 12-14 13:08 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root   36 12-14 13:08 authz_default.load -> ../mods-available/authz_default.load
lrwxrwxrwx 1 root root   38 12-14 13:08 authz_groupfile.load -> ../mods-available/authz_groupfile.load
lrwxrwxrwx 1 root root   33 12-14 13:08 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root   33 12-14 13:08 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root   32 12-14 13:08 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root   32 12-14 13:08 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root   26 12-14 13:08 cgi.load -> ../mods-available/cgi.load
lrwxrwxrwx 1 root root   30 12-14 13:08 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root   30 12-14 13:08 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root   26 12-14 13:08 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root   26 12-14 13:08 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root   26 12-14 13:08 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root   27 12-14 13:08 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root   27 12-14 13:08 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root   35 12-14 13:44 mod-security.load -> ../mods-available/mod-security.load
lrwxrwxrwx 1 root root   34 12-14 13:08 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root   34 12-14 13:08 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root   27 12-14 13:09 perl.load -> ../mods-available/perl.load
lrwxrwxrwx 1 root root   27 12-19 11:16 php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root   27 12-19 11:16 php5.load -> ../mods-available/php5.load
lrwxrwxrwx 1 root root   29 12-14 13:09 python.load -> ../mods-available/python.load
lrwxrwxrwx 1 root root   33 12-14 13:08 reqtimeout.conf -> ../mods-available/reqtimeout.conf
lrwxrwxrwx 1 root root   33 12-14 13:08 reqtimeout.load -> ../mods-available/reqtimeout.load
lrwxrwxrwx 1 root root   30 12-14 13:56 rewrite.load -> ../mods-available/rewrite.load
lrwxrwxrwx 1 root root   31 12-14 13:08 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root   31 12-14 13:08 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root   26 12-14 13:56 ssl.conf -> ../mods-available/ssl.conf
lrwxrwxrwx 1 root root   26 12-14 13:56 ssl.load -> ../mods-available/ssl.load
lrwxrwxrwx 1 root root   29 12-14 13:08 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root   29 12-14 13:08 status.load -> ../mods-available/status.load
lrwxrwxrwx 1 root root   32 12-14 13:44 unique_id.load -> ../mods-available/unique_id.load
/etc/apache2/ports.conf

Kod: Zaznacz cały

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>
    Listen 443
</IfModule>
/etc/apache2/sites-available/default

Kod: Zaznacz cały

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>
/etc/apache2/sites-available/default-ssl

Kod: Zaznacz cały

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
                Options Indexes MultiViews FollowSymLinks
                AllowOverride None
                Order deny,allow
                Deny from all
                Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>

        SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache2.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache2.key

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>

       BrowserMatch "MSIE [2-6]" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0
        # MSIE 7 and newer should be able to use keepalive
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

</VirtualHost>
</IfModule>
/etc/apache2/sites-available/domena1.pl

Kod: Zaznacz cały

<VirtualHost *:80>
        ServerName [url=http://www.test.domena1.pl]www.test.domena1.pl[/URL]
        ServerAdmin [EMAIL="webmaster@domena1.pl"]webmaster@domena1.pl[/EMAIL]
        ServerAlias test.domena1.pl

        DocumentRoot /home/test/public_html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/test/public_html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

        Alias /javascript/ /home/test/public_html/javascript/
        <Directory "/home/test/public_html/javascript/">
        Options Indexes FollowSymLinks MultiViews
        </Directory>

        <Location />
        RewriteEngine on
        RewriteCond %{HTTPS} off
        RewriteRule ^(.*)$ [URL]https://www.test.domena1.pl[/URL] [R]
        </Location>

</VirtualHost>
/etc/apache2/site-available/domena1.pl-ssl

Kod: Zaznacz cały

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName [url=http://www.test.domena1.pl]www.test.domena1.pl[/URL]
        ServerAdmin [EMAIL="webmaster@domena1.pl"]webmaster@domena1.pl[/EMAIL]
        ServerAlias test.domena1.pl

        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/apache2.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache2.key

        DocumentRoot /home/test/public_html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/test/public_html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn


        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

        Alias /javascript/ /home/test/public_html/javascript/
        <Directory "/home/test/public_html/javascript/">
        Options FollowSymLinks MultiViews
        </Directory>

</VirtualHost>
</IfModule>

Dodane:

Witam.

Naprawdę nikt nie wie? Dodam, że na drugim serwerze mam taką samą konfigurację i jest wszystko w porządku.
ODPOWIEDZ