regenerate a correct vhost

Discussion in 'Installation/Configuration' started by kameleon1er, Jun 26, 2022.

  1. kameleon1er

    kameleon1er Member

    Hi, I just realised that one of my redirects was looping and not working. Normally I wanted an alias of domain ispConfig to redirect to my main site (wordpress MU)

    I looked at the vhost of the main domain and there, super strange; there are lots of repetitions in the file. Several times "DocumentRoot" the aliases of the attached domains, the ssl etc... and the redirects.

    What is the cleanest way to regenerate this vhost? From ispConfig.

    Thank you for your help
     
  2. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    If I remember correctly, I think I enabled vhost for each alias domain under WPMU. I don't think I need to use redirect for it. To note, mine is an nginx web server, so running apache2 may be differrent.
     
  3. kameleon1er

    kameleon1er Member

    hi @ahrasis ,
    My WPMU is configured in subdirectories, here is my scenario;
    I had a site for an organisation:
    my_WPMU/organisation1 <--> isp_AliasDomain_x

    The organisation has changed its name and domain.

    To keep the existing content, I cloned the WPress_site to a new location ;

    my_WPMU/new_organisation <--> isp_AliasDomain_y

    But for SEO purposes, I did a 301 redirect from isp_AliasDomain_x to isp_AliasDomain_y.

    That's why I think I need to use an Apache redirect from ispConfig.

    As I had some small problems during the ispC + Debian upgrade, I think some operations might have been duplicated.
     
  4. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Agreed WPMU use either domain (this include sub domain) or sub directory. It never used redirect. But if your setup was working before the upgrade, then you just need to find the fault. Can't help you there. Good luck.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Edit the site settings, change a value (e.g. increase quota) and press save.
     
  6. kameleon1er

    kameleon1er Member

    Hi @till , no effect…
    the system has created this kind of thing in the file, seems "derectives-clone" inside the file :
    and 4 times :
    Code:
        RewriteEngine on
            RewriteCond %{REQUEST_URI} ^/\.well-known/acme-challenge/
            RewriteRule ^ - [END]
            RewriteCond %{HTTP_HOST}   ^opaz-ateliers\.com$ [NC]
            
            RewriteRule   ^/(.*)$ https://opaz-ateliers.com  [R=301,L]
    
            RewriteCond %{HTTP_HOST}   ^www\.opaz-ateliers\.com$ [NC]
            
            RewriteRule   ^/(.*)$ https://opaz-ateliers.com  [R=301,L]
    
    I think I have to modify manually in /sites-available...

    no problem for isp ?

    But there are a lot of lines to comment on.
     
  7. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    I think if you added them in directive column you should remove that first, not manually in the vhost file, because they'll be overwritten each time the website setting is resync'ed or updated.
     
  8. kameleon1er

    kameleon1er Member

    how ? ispConfig >Alias Domain > delete redirection ?
     
  9. kameleon1er

    kameleon1er Member

    Done ! But stil have duplicate directives for :80 et 443. Redirections directives are gone.
    After, in terminal I tried service apache2 reload :
    Code:
    ● apache2.service - The Apache HTTP Server
       Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
       Active: active (running) since Mon 2022-06-27 00:08:20 UTC; 4min 32s ago
         Docs: https://httpd.apache.org/docs/2.4/
      Process: 20265 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
      Process: 22375 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
        Tasks: 39 (limit: 4915)
       Memory: 152.4M
       CGroup: /system.slice/apache2.service
               ├─20302 /usr/sbin/apache2 -k start
               ├─22384 vlogger (access log)
               ├─22385 /usr/sbin/apache2 -k start
               ├─22386 Passenger watchdog
               ├─22389 Passenger core
               ├─22398 Passenger ust-router
               ├─22416 /usr/sbin/apache2 -k start
               ├─22417 /usr/sbin/apache2 -k start
               ├─22418 /usr/sbin/apache2 -k start
               ├─22419 /usr/sbin/apache2 -k start
               ├─22420 /usr/sbin/apache2 -k start
               ├─22421 /usr/bin/php-cgi -d open_basedir=/var/www/clients/client0/web3/web:/var/www/clients/client0/web3/private:/var/www/clients/client0/web3/tmp:/var/www/lucifart.com/web:/srv/www/lucif
               ├─22422 /usr/sbin/apache2 -k start
               ├─22423 /usr/sbin/apache2 -k start
               ├─22424 /usr/bin/php-cgi -d disable_classes= -d disable_functions= -d magic_quotes_gpc=off -d open_basedir= -d session.save_path=/usr/local/ispconfig/interface/temp
               └─22425 /usr/bin/php-cgi -d disable_classes= -d disable_functions= -d magic_quotes_gpc=off -d open_basedir= -d session.save_path=/usr/local/ispconfig/interface/temp
    
    Jun 27 00:08:20 srv-b.democrasite.com systemd[1]: Starting The Apache HTTP Server...
    Jun 27 00:08:20 srv-b.democrasite.com apachectl[20265]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/000-ispconfig.vhost:7
    Jun 27 00:08:20 srv-b.democrasite.com systemd[1]: Started The Apache HTTP Server.
    Jun 27 00:12:30 srv-b.democrasite.com systemd[1]: Reloading The Apache HTTP Server.
    Jun 27 00:12:30 srv-b.democrasite.com apachectl[22375]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/000-ispconfig.vhost:7
    Jun 27 00:12:30 srv-b.democrasite.com systemd[1]: Reloaded The Apache HTTP Server.
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    There must be two vhost sections, one for each port. So there is nothing duplicated unless you have vhost section dulicates where port and IP are the same.
     
    ahrasis likes this.
  11. kameleon1er

    kameleon1er Member

    Back :) I looked a little closer, and indeed there is a vhosts that is weird:
    For all declared domains (Websites section) there is "domain_name.vhost" with ::80 and 443 directives in the same file, seems to be OK :
    But for these democrasite.com.vhost and democrasite.com.vhost-le-ssl.conf
    for the first one I just have *:80 directives twice but in the second only have :*:443 directives :
    Code:
    <Directory /var/www/democrasite.com>
            AllowOverride None
                    Require all denied
            </Directory>
    
    <VirtualHost *:80>
    
    
                                        DocumentRoot /var/www/democrasite.com/web
                           
            ServerName democrasite.com
            ServerAlias www.democrasite.com
        ServerAlias www.opaz-ateliers.com opaz-ateliers.com
        ServerAlias www.vmxparis.com vmxparis.com
        ServerAlias www.ianpatrickimages.com ianpatrickimages.com
        ServerAlias www.alainroussel.com alainroussel.com
        ServerAlias www.alleray.fr alleray.fr
        ServerAlias www.auberjazzday.fr auberjazzday.fr
        ServerAlias www.cobaltateliers.com cobaltateliers.com
        ServerAlias www.sandybeearts.com sandybeearts.com
            ServerAdmin [email protected]
    
    
            ErrorLog /var/log/ispconfig/httpd/democrasite.com/error.log
    
            Alias /error/ "/var/www/democrasite.com/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
    
            <Directory /var/www/democrasite.com/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +SymlinksIfOwnerMatch
                    AllowOverride All
                                    Require all granted
                            </Directory>
            <Directory /var/www/clients/client0/web2/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +SymlinksIfOwnerMatch
                    AllowOverride All
                                    Require all granted
                            </Directory>
    
    
    
    
            # suexec enabled
            <IfModule mod_suexec.c>
                SuexecUserGroup web2 client0
            </IfModule>
            # php as fast-cgi enabled
        # For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
            <IfModule mod_fcgid.c>
                    FcgidIdleTimeout 300
                    FcgidProcessLifeTime 3600
                    # FcgidMaxProcesses 1000
                    FcgidMaxRequestsPerProcess 5000
                    FcgidMinProcessesPerClass 0
                    FcgidMaxProcessesPerClass 10
                    FcgidConnectTimeout 3
                    FcgidIOTimeout 600
                    FcgidBusyTimeout 3600
                    FcgidMaxRequestLen 1073741824
            </IfModule>
            <Directory /var/www/democrasite.com/web>
                    <FilesMatch "\.php[345]?$">
                        SetHandler fcgid-script
                    </FilesMatch>
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php3
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php4
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php5
                    Options +ExecCGI
                    AllowOverride All
                                    Require all granted
                            </Directory>
            <Directory /var/www/clients/client0/web2/web>
                    <FilesMatch "\.php[345]?$">
                        SetHandler fcgid-script
                    </FilesMatch>
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php3
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php4
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php5
                    Options +ExecCGI
                    AllowOverride All
                                    Require all granted
                            </Directory>
    
    
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web2 client0
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client0/web2/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client0/web2/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    
               
       
    
    </VirtualHost>
    
    
    <VirtualHost [2001:bc8:47b0:170a::1]:80>
    
    
                                        DocumentRoot /var/www/democrasite.com/web
                           
            ServerName democrasite.com
            ServerAlias www.democrasite.com
        ServerAlias www.opaz-ateliers.com opaz-ateliers.com
        ServerAlias www.vmxparis.com vmxparis.com
        ServerAlias www.ianpatrickimages.com ianpatrickimages.com
        ServerAlias www.alainroussel.com alainroussel.com
        ServerAlias www.alleray.fr alleray.fr
        ServerAlias www.auberjazzday.fr auberjazzday.fr
        ServerAlias www.cobaltateliers.com cobaltateliers.com
        ServerAlias www.sandybeearts.com sandybeearts.com
            ServerAdmin [email protected]
    
    
            ErrorLog /var/log/ispconfig/httpd/democrasite.com/error.log
    
            Alias /error/ "/var/www/democrasite.com/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
    
            <Directory /var/www/democrasite.com/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +SymlinksIfOwnerMatch
                    AllowOverride All
                                    Require all granted
                            </Directory>
            <Directory /var/www/clients/client0/web2/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +SymlinksIfOwnerMatch
                    AllowOverride All
                                    Require all granted
                            </Directory>
    
    
    
    
            # suexec enabled
            <IfModule mod_suexec.c>
                SuexecUserGroup web2 client0
            </IfModule>
            # php as fast-cgi enabled
        # For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
            <IfModule mod_fcgid.c>
                    FcgidIdleTimeout 300
                    FcgidProcessLifeTime 3600
                    # FcgidMaxProcesses 1000
                    FcgidMaxRequestsPerProcess 5000
                    FcgidMinProcessesPerClass 0
                    FcgidMaxProcessesPerClass 10
                    FcgidConnectTimeout 3
                    FcgidIOTimeout 600
                    FcgidBusyTimeout 3600
                    FcgidMaxRequestLen 1073741824
            </IfModule>
            <Directory /var/www/democrasite.com/web>
                    <FilesMatch "\.php[345]?$">
                        SetHandler fcgid-script
                    </FilesMatch>
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php3
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php4
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php5
                    Options +ExecCGI
                    AllowOverride All
                                    Require all granted
                            </Directory>
            <Directory /var/www/clients/client0/web2/web>
                    <FilesMatch "\.php[345]?$">
                        SetHandler fcgid-script
                    </FilesMatch>
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php3
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php4
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php5
                    Options +ExecCGI
                    AllowOverride All
                                    Require all granted
                            </Directory>
    
    
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web2 client0
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client0/web2/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client0/web2/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    
               
       
    
    </VirtualHost>
    
    Code:
    <IfModule mod_ssl.c>
    <VirtualHost *:443>
    
    
                                        DocumentRoot /var/www/democrasite.com/web
                           
            ServerName democrasite.com
            ServerAlias www.democrasite.com
        ServerAlias www.opaz-ateliers.com opaz-ateliers.com
        ServerAlias www.vmxparis.com vmxparis.com
        ServerAlias www.ianpatrickimages.com ianpatrickimages.com
        ServerAlias www.alainroussel.com alainroussel.com
        ServerAlias www.alleray.fr alleray.fr
        ServerAlias www.auberjazzday.fr auberjazzday.fr
        ServerAlias www.cobaltateliers.com cobaltateliers.com
        ServerAlias www.sandybeearts.com sandybeearts.com
            ServerAdmin [email protected]
    
    
            ErrorLog /var/log/ispconfig/httpd/democrasite.com/error.log
    
            Alias /error/ "/var/www/democrasite.com/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
    
            <Directory /var/www/democrasite.com/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +SymlinksIfOwnerMatch
                    AllowOverride All
                                    Require all granted
                            </Directory>
            <Directory /var/www/clients/client0/web2/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +SymlinksIfOwnerMatch
                    AllowOverride All
                                    Require all granted
                            </Directory>
    
    
    
    
            # suexec enabled
            <IfModule mod_suexec.c>
                SuexecUserGroup web2 client0
            </IfModule>
            # php as fast-cgi enabled
        # For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
            <IfModule mod_fcgid.c>
                    FcgidIdleTimeout 300
                    FcgidProcessLifeTime 3600
                    # FcgidMaxProcesses 1000
                    FcgidMaxRequestsPerProcess 5000
                    FcgidMinProcessesPerClass 0
                    FcgidMaxProcessesPerClass 10
                    FcgidConnectTimeout 3
                    FcgidIOTimeout 600
                    FcgidBusyTimeout 3600
                    FcgidMaxRequestLen 1073741824
            </IfModule>
            <Directory /var/www/democrasite.com/web>
                    <FilesMatch "\.php[345]?$">
                        SetHandler fcgid-script
                    </FilesMatch>
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php3
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php4
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php5
                    Options +ExecCGI
                    AllowOverride All
                                    Require all granted
                            </Directory>
            <Directory /var/www/clients/client0/web2/web>
                    <FilesMatch "\.php[345]?$">
                        SetHandler fcgid-script
                    </FilesMatch>
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php3
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php4
                    FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php5
                    Options +ExecCGI
                    AllowOverride All
                                    Require all granted
                            </Directory>
    
    
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web2 client0
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client0/web2/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client0/web2/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    
               
       
    
    
    
    
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/democrasite.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/democrasite.com/privkey.pem
    </VirtualHost>
    </IfModule>
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    This means you manually used certbot on the shell and certbot broke your server config. never use certbot manually to create a SSL cert for an ISPConfig website as certbot is not able to edit the config file properly and will destroy the site config.

    To fix your problem, delete all vhost files with "vhost-le-ssl.conf" at the end of the filename. Then login to ISPConfig and use the Let#s encrypt checkbox of the website if you want to get a let#s encrypt SSL certificate for the site.
     
  13. kameleon1er

    kameleon1er Member

    Yes, I don't remember, but probably yes in the past, use certbot manually. Is it possible to use it anyway with dry run when searching for a config bug ?
     
  14. kameleon1er

    kameleon1er Member

    Doesn't work… "WARNING - Let's Encrypt SSL Cert for: democrasite.com could not be issued. " Stay unchecked in isp (ssl and LE).
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

  16. till

    till Super Moderator Staff Member ISPConfig Developer

    As long as you don't use it to issue SSL certs manually and let it edit config files, then that's ok.
     
  17. kameleon1er

    kameleon1er Member

    done, follow >
    Vhost seems to be ok >SSL Report on Ssllabs = A grade..
    But now I have a error 500 on the website.
     
  18. kameleon1er

    kameleon1er Member

    It's ok now. Thanks @till
     
  19. Peter Oudenes

    Peter Oudenes New Member

    I get also a error:
    Code:
    Mar 27 11:56:08 mail systemd[1]: Starting The Apache HTTP Server...
    Mar 27 11:56:08 mail apachectl[704117]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/000-ispconfig.vhost:7
    this file is look like this:

    Code:
    ######################################################
    # This virtual host contains the configuration
    # for the ISPConfig controlpanel
    ######################################################
     Listen 8080
    NameVirtualHost *:8080
    <VirtualHost _default_:8080>
      ServerAdmin webmaster@localhost
      Alias /mail /var/www/ispconfig/mail
    ............
     
  20. till

    till Super Moderator Staff Member ISPConfig Developer

    That's not an error. So nothing is wrong with that vhost. It's just compatible with older Apache versions as well. This is just an info message. Nothing to worry about.
     
    Peter Oudenes likes this.

Share This Page