Website config changes, now points to wrong vhost

Discussion in 'General' started by blinden, Sep 27, 2018.

  1. blinden

    blinden Member

    I have a customer that wanted to setup a temporary site parallel to their existing site while they updated the site. The original site was hosted on a 3rd party server, but I had an A record added for xx.domain.com and setup xx.domain.com as a site in ISPConfig.

    They have completed their work on their new site, and asked me to make it live, so I changed the A records for www and * to the IP of my ISPConfig webserver. I then went in and edited the site, removed the xx from the domain and changed it to auto subdomain of * (I have also tried www)

    The apache vhost file updates properly with the changes I make, however going to the domain now loads a different site on the same server (Alphabetically the first vhost on the system, FWIW).

    I've tried changing the config in all manners I can think of, but it seems like it ignores the vhost in the sites-enabled directory and just loads that other vhost for some reason.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Ensure to not mix * and Ip in the IPv4 field of the websites on your server, either all sites must use the Ip or all sites must use *.
     
  3. blinden

    blinden Member

    They are all *
     
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    So you write something.domain.com in browser, but end up at some other site? Are you sure you do have a website named something.domain.com at your server?
     
  5. blinden

    blinden Member

    It also redirects the webpage, now if I put in www.domain.com it redirects to xx.domain.com (the original temporary site I had installed) and continues to load the first available vhost.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Have all sites ssl or just some sites or just this one site while other sites on the same IP have no ssl enabled?
     
  7. blinden

    blinden Member

    Most of them have SSL, this one does not because I was going to enable it once I got it one the permanent domain name.

    I have tried turning on SSL on this site as well, using the letsencrypt function (which is awesome, thanks for implementing that so seamlessly) . It's like apache is just ignoring the vhost for this site for some reason.
     
  8. blinden

    blinden Member

    I've reverted everything back (the domain name, auto subdomain, etc) and turned SSL on and I'm able to load the site, now I just need to figure out how to move it to the new, correct domain.
     
  9. blinden

    blinden Member

    So, just for testing, I tried to disable my xx.domain.com site and I got an error:

    Sep 27 12:02:09 Ispconfig-Web1 apache2[18322]: * The apache2 configtest failed.
    Sep 27 12:02:09 Ispconfig-Web1 apache2[18322]: Output of config test was:
    Sep 27 12:02:09 Ispconfig-Web1 apache2[18322]: AH00526: Syntax error on line 1 of /etc/apache2/sites-enabled/.100-xx.domain.com.vhost.swp:
    Sep 27 12:02:09 Ispconfig-Web1 apache2[18322]: Invalid command 'b0nano', perhaps misspelled or defined by a module not included in the server configuration
    Sep 27 12:02:09 Ispconfig-Web1 apache2[18322]: Action 'configtest' failed.
    Sep 27 12:02:09 Ispconfig-Web1 apache2[18322]: The Apache error log may have more information.
    Sep 27 12:02:09 Ispconfig-Web1 systemd[1]: apache2.service: Control process exited, code=exited status=1
    Sep 27 12:02:09 Ispconfig-Web1 systemd[1]: Failed to start LSB: Apache2 web server.
    Sep 27 12:02:09 Ispconfig-Web1 systemd[1]: apache2.service: Unit entered failed state.
    Sep 27 12:02:09 Ispconfig-Web1 systemd[1]: apache2.service: Failed with result 'exit-code'.
    When I turn the site back on, apache comes back up and the site is available.

    The file sited .100-xx.domain.com.vhost.swp is just a bunch of characters, almost looks like a binary file.
     
  10. Jesse Norell

    Jesse Norell Well-Known Member

    that is a temporary file created by your editor, just make sure your editor (vi?) is closed, then remove it.


    That is probably done by the site itself. Eg. in wordpress you would need to set the site URL, and other cms software usually has a similar setting.
     
  11. blinden

    blinden Member

    The problem is, the actual vhost file is gone


    Yup, good thinking.
     
  12. blinden

    blinden Member

    So, I've corrected these issues, I've returned the DNS to point to the original server, I'm trying to work through this problem on the ispconfig host before I move the A record.

    I'm using hosts enteries on my local machine to try and get the issues resolved, and I'm running into the same problems. Once I change the domain from xx.domain.com to just domain.com the vhost seems to be ignored by apache and it's loading the alphabetically first vhost config for the domain.
     
  13. Jesse Norell

    Jesse Norell Well-Known Member

    For future reference, to recover:
    Code:
    cd /etc/apache2/sites-enabled/
    vi -r 100-xx.domain.com.vhost
    Then save to a new filename (you could save as 100-xx.domain.com.vhost as the file didn't exist), exit the editor and remove the .swp file. Or just edit a setting in the site in ISPConfig and it'll generate the file again. :)

    What it sounds like is once you change the name in ispconfig and access it as "domain.com," the site itself redirects to xx.domain.com, which your browser follows and requests from apache - but there is no such site defined in apache config, so it gives you the server's default site. Now if you really did set the subdomain to *. it should have caught the xx.domain.com name as well I believe (I don't know if I've ever tried that), so there must be one other piece missing from the puzzle, eg. check all sites on the server and make sure you have not mixed the ip address in some place(s) with '*' for the ip address in other places, use one or the other consistently.
     
  14. blinden

    blinden Member

    Yup, figured that out after a bit of trial and error, thanks.

    I did a grep on the ../apache2/sites-available directory for the IP address and there were no returns, none of the vhost configs are using IP address.

    In the end, it's working now, I setup everything and rebooted the server and everything works out like I expected after that.
     

Share This Page