Ispconfig web interface : rewrite in .vhost

Discussion in 'Installation/Configuration' started by francoisPE, Oct 19, 2020.

  1. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Hi,
    I am currently setting up ispconfig3 on ubuntu 18.04.
    I run
    cd /tmp; wget --no-check-certificate -O installer.tgz "https://github.com/servisys/ispconfig_setup/tarball/master"; tar zxvf installer.tgz; cd *ispconfig*; bash install.sh
    I am on multiserver config with Apache, mariadb, and other standards
    All is working good.

    I see that when I send a request to port 8080 whatever the domain (exam.tlp, sub.exam.tld, server.exam.tld) it goes to ispconfig web interface.
    I have letsencrypt cert on server.exam.tlp only.
    So that, I would like to answer only with server.exam.tld to avoid alert due to security concerns.

    To do so, I am modifying /etc/apache2/sites-enabled/000-ispconfig.vhost

    First I add "ServerName server.exam.tld" just after
    "
    ...
    <VirtualHost _default_:8080>
    ServerAdmin webmaster@localhost
    ServerName server.exam.tld
    ...
    "
    but I hadn't result !

    Now I try rewrite doing :
    "
    Listen 8080
    NameVirtualHost *:8080
    <VirtualHost _default_:8080>
    ServerAdmin webmaster@localhost
    RewriteEngine On
    RewriteCond "%{SERVER_PORT}" "^8080$"
    RewriteRule "(.*)" "https://server.exam.tld:8080"
    "
    but Mozilla answer to "exam.tld:8080"
    is
    "
    https://exam.tld:8080/index.html/in.../index.html/index.html/index.html/index.html/
    "
    This is not exactly what I want.
    I would like "https://server.exam.tld:8080"
    I don't see my mistake.
    Thanks
     
  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    What does 'apachectl -S' show ?
     
  3. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    1. It is not advisable to edit ispconfig.vhost directly or via symlink as it will be overwriiten with default during update.
    2. It is advise to use conf-custom if you really need to customize the same.
    3. Ensure your php (with all of its required dependencies) for ISPConfig is the default shipped with your OS.
    4. Ensure restarting apache each time you manually make a change to vhost files to see its effects but do note it will be overwritten when ISPConfig is resynced or updated.
     
  4. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    I moved your thread to the ISPConfig 3 forum board.
     
  5. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Hi,
    Many thanks for your helps. :)
    @ahrasis that's written when you do apachectl -S (in bold)
    @Jesse Norell Here below, w/O and with vhost modified (IP : x.y.z modified by myself)
    I see no differences !

    I will try the modification in conf-custom.
    Where can I find it for ISPconfig ?

    "
    root@server1:~# apachectl -S
    AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/000-ispconfig.vhost:7
    VirtualHost configuration:
    x.y.z.64:80 exam.tld (/etc/apache2/sites-enabled/100-exam.tld.vhost:7)
    1x.y.z.64:443 exam.tld (/etc/apache2/sites-enabled/100-exam.tld.vhost:127)
    *:8081 server1.exam.tld (/etc/apache2/sites-enabled/000-apps.vhost:9)
    *:8080 server1.exam.tld (/etc/apache2/sites-enabled/000-ispconfig.vhost:9)
    *:80 is a NameVirtualHost
    default server server1.exam.tld (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost server1.exam.tld (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost wp.exam.tld (/etc/apache2/sites-enabled/100-wp.exam.tld.vhost:7)
    alias www.wp.exam.tld
    ServerRoot: "/etc/apache2"
    Main DocumentRoot: "/var/www/html"
    Main ErrorLog: "/var/log/apache2/error.log"
    Mutex proxy: using_defaults
    Mutex ssl-cache: using_defaults
    Mutex default: dir="/var/run/apache2/" mechanism=default
    Mutex mpm-accept: using_defaults
    Mutex fcgid-pipe: using_defaults
    Mutex authdigest-opaque: using_defaults
    Mutex watchdog-callback: using_defaults
    Mutex rewrite-map: using_defaults
    Mutex ssl-stapling-refresh: using_defaults
    Mutex authdigest-client: using_defaults
    Mutex fcgid-proctbl: using_defaults
    Mutex ssl-stapling: using_defaults
    PidFile: "/var/run/apache2/apache2.pid"
    Define: DUMP_VHOSTS
    Define: DUMP_RUN_CFG
    Define: ENABLE_USR_LIB_CGI_BIN
    User: name="www-data" id=33
    Group: name="www-data" id=33
    root@server1:~# nano /etc/apache2/sites-enabled/000-ispconfig.vhost (I made the change)
    root@server1:~# service apache2 restart
    root@server1:~# apachectl -S
    AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/000-ispconfig.vhost:7
    VirtualHost configuration:
    x.y.z.64:80 exam.tld (/etc/apache2/sites-enabled/100-exam.tld.vhost:7)
    x.y.z.64:443 exam.tld (/etc/apache2/sites-enabled/100-exam.tld.vhost:127)
    *:8081 server1.exam.tld (/etc/apache2/sites-enabled/000-apps.vhost:9)
    *:8080 server1.exam.tld (/etc/apache2/sites-enabled/000-ispconfig.vhost:9)
    *:80 is a NameVirtualHost
    default server server1.exam.tld (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost server1.exam.tld (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost wp.exam.tld (/etc/apache2/sites-enabled/100-wp.exam.tld.vhost:7)
    alias www.wp.exam.tld
    ServerRoot: "/etc/apache2"
    Main DocumentRoot: "/var/www/html"
    Main ErrorLog: "/var/log/apache2/error.log"
    Mutex rewrite-map: using_defaults
    Mutex ssl-stapling-refresh: using_defaults
    Mutex authdigest-client: using_defaults
    Mutex fcgid-proctbl: using_defaults
    Mutex ssl-stapling: using_defaults
    Mutex proxy: using_defaults
    Mutex ssl-cache: using_defaults
    Mutex default: dir="/var/run/apache2/" mechanism=default
    Mutex mpm-accept: using_defaults
    Mutex fcgid-pipe: using_defaults
    Mutex authdigest-opaque: using_defaults
    Mutex watchdog-callback: using_defaults
    PidFile: "/var/run/apache2/apache2.pid"
    Define: DUMP_VHOSTS
    Define: DUMP_RUN_CFG
    Define: ENABLE_USR_LIB_CGI_BIN
    User: name="www-data" id=33
    Group: name="www-data" id=33
     
  6. francoisPE

    francoisPE Active Member HowtoForge Supporter

    This is what I found out !

    root@server1:/usr/local/ispconfig/server/conf-custom# ls -lrtA *
    -rwxr-x--- 1 root root 45 Oct 19 16:47 empty.dir

    mail:
    total 4
    -rwxr-x--- 1 root root 45 Oct 19 16:47 empty.dir

    install:
    total 4
    -rwxr-x--- 1 root root 45 Oct 19 16:47 empty.dir

    error:
    total 4
    -rwxr-x--- 1 root root 45 Oct 19 16:47 empty.dir

    index:
    total 4
    -rwxr-x--- 1 root root 45 Oct 19 16:47 empty.dir
     
  7. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    Copy the corresponding template file from the conf/ directory to conf-custom/, and make your changes in the latter file.

    From what I see I would expect the server1 name to stay in the URL. Have you tried a different browser or different machine? Your browser can remember a previous redirect that might not be there in your current configuration.

    If you want to post the actual hostname we could check it externally.
     
  8. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Here what I did.
    Not sure it is correct
    root@server1:/usr/local/ispconfig/server/conf# cp apache_apps.vhost.master /usr/local/ispconfig/server/conf-custom
    root@server1:/usr/local/ispconfig/server/conf-custom# nano apache_apps.vhost.master
    "
    ######################################################
    # This virtual host contains the configuration
    # for the ISPConfig apps vhost
    ######################################################

    {tmpl_var name='vhost_port_listen'} Listen {tmpl_var name='apps_vhost_port'}
    # NameVirtualHost *:{tmpl_var name='apps_vhost_port'}

    <VirtualHost {tmpl_var name='apps_vhost_ip'}:{tmpl_var name='apps_vhost_port'}>
    ServerAdmin webmaster@localhost
    {tmpl_var name='apps_vhost_servername'}
    RewriteEngine On
    RewriteCond "%{SERVER_PORT}" "^8080$"
    RewriteRule "(.*)" "https://server1.exam.tld:8080"

    <FilesMatch "\.ph(p3?|tml)$">
    SetHandler None
    </FilesMatch>
    "
    next,
    root@server1:/usr/local/ispconfig/server/conf-custom# service apache2 restart
    next in browser : https://x.y.z.64:8080/ (IP : x.y.z modified by myself)
    unfortunately, no changes !
     
  9. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    if all you've done is copied the template file to conf-custom and then edited it there, then it hasn't made any changes to the live configuration. i'm not sure if a resync of websites will affect the interface config. might need to force an ispconfig update.

    also, if it's the ispconfig interface you're trying to affect (port 8080), shouldn't you be using the apache_ispconfig_vhost.master template from the install tarball ispconfig3-install/install/tpl folder, which i believe should be copied to /usr/local/ispconfig/server/conf-custom/install/
    the apache_apps_vhost.master is for stuff usually on port 8081.
     
    ahrasis likes this.
  10. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Fully right.
    It works doing like this. Nevertheless, I forgive this solution that leads to custom conf to manage when ISP will be updated !
     
    ahrasis likes this.

Share This Page