Custom vhost contents revert after changes

Discussion in 'ISPConfig 3 Priority Support' started by pebkac, Aug 20, 2018.

  1. pebkac

    pebkac Member

    Hey all,

    How can we keep custom content that we have in
    /etc/apache2/sites-available/domain.com.vhost

    Seems any change we make, even as simple as adding new subdomains that file reverts back to ispconfig defaults and breaks some custom settings we have. Currently I have to delete the file and restore a copy of our working file.

    How can we avert having to do that and just have it survive changes?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Do not edit vhost files manually, instead custom changes should be added in the apache (or nginx) directives field of the website in ISPConfig.
     
  3. pebkac

    pebkac Member

    Hi till. I know that now, unfortunaltey we had a dev make some changes and now I don't know how to take his changes and put them into the apache directives in ISPConfig. I'm going to private message you the two files, one is the one that the changes our dev did have and the other is the ISPConfig generated one. If you run diff -y on the two files you can see the changes made, mostly at the bottom of the files. Is there a way to add those to the Apache Directive in ISPC3?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    You should be able to do that from within ispconfig. Remove the alias domains that you don't want to use anymore, add the alias domains that are not added in ISPConfig yet and then add the additional rewrite rule config in the apache directives field.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    I just noticed he added also some other vhosts into the file of that site, this won't work. To enable SSL for a website, you tick the SSL checkbox of the site and add the SSL cert in ISPConfig, you do not edit a file for that. and if you want to use sub-vhosts on a site to point to a specific subdirectory, then you use vhost aliasdomains for that. Your dev really messed up the config there, he does not seem to know that he could have aet it up in ISPConfig.

    If you want to keep that config file without being able to use ISPConfig in future, then you can make the vhost file immutable with the chattr +i command.
     
  6. pebkac

    pebkac Member

    Thanks for the info. However, I'm still not sure how to make the necessary changes in ISPC3 to make this work like he did. This is what he wants us to do.
    Code:
    1) these lines should be commented out or removed from the `main` virtual hosts setup (both 80 and 443):
    # ServerName domain.info
    # ServerAlias www.domain.info
    # dev1.domain.info
    
    2) that part of code should be removed too from the main virtual host setup section (for both 80 and 443):
    RewriteCond %{HTTP_HOST}   ^dev1\.domain\.info$ [NC]
    RewriteCond %{REQUEST_URI} !^/webdav/
    RewriteCond %{REQUEST_URI} !^/php5-fcgi/
    RewriteCond %{REQUEST_URI} !^/subdomains/dev1/www/
    RewriteRule   ^/(.*)$ /subdomains/dev1/www/$1  [L]
    So the domain.info is our root site in ISPC3, which has the docroot as /var/www/clients/client1/web1. Subdomains are located in /var/www/clients/client1/web1/subdomains/. This dev created a new site for us and we are using it as domain.info, why he did not just place everything in the docroot is beyond me. He created the directories for the new site under /subdomains/live and dev1 for the dev site for that new site. Is it even possible to make this work like he does with the edits he did manually?
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    1) the domains and subdomains get listed there ebcause you set them as domain for the site and / or as alias or subdomains of that site in ISPConfig.
    2) You seem to have setup a redirect for the dev1 subdomain in ISPConfig, by removing the redirect, the redirect config wwill get removed.

    That's probably the easiest option as he altered the vhost config so much instead of using ISPConfig to achieve the same thing. I posted this last option already above:

    You can not use ISPConfig to manage that site then anymore. to make the config file immutable, use:

    chattr +i /etc/apache2/sites-available/yourdomain.tld.vhost

    The path needs to be changed to the path of the vhost file of that site.
     

Share This Page