Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: VirtualHosts only looks at first instance

  1. #1

    Default VirtualHosts only looks at first instance

    Hey all,

    So I've done a bunch of google and forum searching on this, but I'm stuck! I'm just trying to do simple name-based virtual hosting (different domains/content, same IP).

    What I've done is uncomment the "NameVirtualHost *:80" line in listen.conf. Then I have one file "domain.conf" in vhosts.d/ with:

    Code:
    <VirtualHost *:80>
    ServerName www.domain1.com
    DocumentRoot /srv/www/htdocs/domain1
    <Directory "/srv/www/htdocs/domain1">
    Options None
    AllowOverride None
    Order allow,deny
     Allow from all
    </Directory>
    
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerName www.domain2.com
    DocumentRoot /srv/www/htdocs/domain2
    <Directory "/srv/www/htdocs/domain2">
    Options None
    AllowOverride None
    Order allow,deny
     Allow from all
    </Directory>
    
    </VirtualHost>
    Now, I actually have many domains, but these are the only 2 vhosts I set up. No matter what domain I go to (even if I just use my IP), it uses whichever <VirtualHost> I put first, in this case, "www.domain1.com"'s root of htdocs/domain1. If I switch that around, and put domain2 first, everything gets directed to htdocs/domain2.


    I have tried:
    • using * instead of *:80
    • separate .conf files for each domain (it just uses the first alphabetically)
    • <myip>:80 and <myip>
    • other things I can't think of



    I just can't figure this out. Ideas?

  2. #2
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: VirtualHosts only looks at first instance

    I assume you are using apache server right?
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  3. #3

    Default Re: VirtualHosts only looks at first instance

    Quote Originally Posted by yasar11732 View Post
    I assume you are using apache server right?
    Sorry, yes.

  4. #4
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: VirtualHosts only looks at first instance

    I don't have apache server installed right now, but I remember using virtual hosts which I set up using yast. So instead of editing config files manually, I would recommend doing your setup through yast. That would be more productive. If you can't figure out how to do that, I might install apache and try to figure out how did I do it earlier.
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  5. #5

    Default Re: VirtualHosts only looks at first instance

    Quote Originally Posted by yasar11732 View Post
    I don't have apache server installed right now, but I remember using virtual hosts which I set up using yast. So instead of editing config files manually, I would recommend doing your setup through yast. That would be more productive. If you can't figure out how to do that, I might install apache and try to figure out how did I do it earlier.
    Tried that, same outcome. Except it switches it all to * instead of *:80

  6. #6
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: VirtualHosts only looks at first instance

    Then I will try to install apache and see what can I do. Maybe I can answer your question in half an hour or so.
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  7. #7
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: VirtualHosts only looks at first instance

    I did my virtual host configuration just fine. I far as I can see, yast only created too files inside vhosts.d called www.yasar1.com www.yasar2.com, their contents are:

    www.yasar2.com

    <VirtualHost *>
    DocumentRoot /home/yasar/public_html/yasar1
    ServerName www.yasar1.com
    ServerAdmin yasar11732@gmail.com
    <Directory /home/yasar/public_html/yasar1>
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>
    www.yasar2.conf
    <VirtualHost *>
    DocumentRoot /home/yasar/public_html/yasar2
    ServerName www.yasar2.com
    ServerAdmin yasar11732@gmail.com
    <Directory /home/yasar/public_html/yasar2>
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  8. #8

    Default Re: VirtualHosts only looks at first instance

    Yes, that's what mine does also. But for every domain, it points it to the doc root defined in the first (alphabetically) conf file.

  9. #9
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: VirtualHosts only looks at first instance

    I tried mine, and it works just fine. I edited earlier post and send printscreen there, maybe you can see there what you have been doing wrong.
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  10. #10

    Default Re: VirtualHosts only looks at first instance

    Edit:

    I figured out the problem. It's something related to the headers not being passed on to my server, so it's not getting the proper domain name Unrelated to vhosts config

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •