Links in e-mails "wrong"

Discussion in 'Installation/Configuration' started by impius, Feb 1, 2022.

  1. impius

    impius New Member

    Hi all
    I just setup and run now a clustered ISPConfig environment with 7 servers. Most questions i had where already answered in manuals and forums.
    I have the problem that all links that gets generated by ISPConfig like password reset link or links in e-mails for logging in to ISPConfig contain the private IP address instead of the public domain name.
    Does anyone knows how to change/set that?

    Thanks in advance
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Is the Hostname under system > Server config set correctly for the node that runs the UI?
     
  3. impius

    impius New Member

    Hi Till, thanks for fast response
    Yes, hostname is set correctly. The link i receive by mail looks as example like this:
    http: // 10.22.0.11:8080/login/password_reset.php?username=xxxxxxxxxxx&hash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    (sorry the spaces, i'm not allowed to send links)

    I'm running the UI behind a reverse proxy to access it by a regular https (port 443) page.
    Is this somewhere coded in mail templates that i can fill in my own domain name without :8080?
     
    Last edited: Feb 1, 2022
    ahrasis likes this.
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    I just had a look at the code and the server name is set by this code:

    Code:
    $server_domain = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']);
                if($server_domain == '_') {
                    $tmp = explode(':',$_SERVER["HTTP_HOST"]);
                    $server_domain = $tmp[0];
                    unset($tmp);
                }
    So PHP seems to have an IP as server name or http host in its $_SERVER array. I guess this can be changed in the code only.
     
    ahrasis likes this.
  5. impius

    impius New Member

    Thanks for checking, so i will have a look where i can modify that.
    Maybe it would be a nice feature for the future to set the URL to use in mails similar to the ones for webmail or the phpmyadmin in the system -> main config
     
    till likes this.
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    The code is in /usr/local/ispconfig/interface/web/login/ in the password reset file.
     
    ahrasis and impius like this.
  7. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    You could probably just add a ServerName directive to your ispconfig vhost config, then $_SERVER['SERVER_NAME'] will be set.
     
    ahrasis, impius and till like this.
  8. impius

    impius New Member

    Hey Jesse
    Thanks for this nice idea, unfortunately this didn't work, for some reason i still get the IP in $_SERVER['SERVER_NAME'].
    Steps i've done :
    Add ServerName directive to file /etc/apache2/sites-enabled/000-ispconfig.vhost
    Reload apache2, restart php7-4-fpm.

    And thanks Till for the path
    I've edited for now the file /usr/local/ispconfig/interface/web/login/password_reset.php and hardcoded the $server_domain.
    This works now fine for password reset, but i have to check now where elsewhere the server domain is needed, as in the help -> send message section or in system -> server config -> "Send email to admin starting with the following level".

    So Jesse's solution with the ServerName directive would be much better if i can get it working... i need to check why this is not working.

    I've setup the whole system on debian 11, but i guess this can't be the problem.
     
  9. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    In looking at that again, if SERVER_NAME is not set, it uses HTTP_HOST - ie. the hostname in the Host: header sent by the client. I just tested on a debian 11 control panel, and the password reset link is sent using the proper hostname, without setting ServerName in the vhost config.

    Are you accessing ISPConfig via a hostname? Does the HTTP connection get forwarded directly to the ISPConfig server, or is there an HTTP reverse proxy involved?
     
    ahrasis likes this.
  10. impius

    impius New Member

    Hi Jesse
    You just pointed me to the problem.
    Yes, ISPConfig UI is behind an apache reverse proxy, the proxy rules point to the ip address and the port 8080.
    I forgot to add the usual "always good idea" directive:
    Code:
    ProxyPreserveHost On
    
    Thanks so much to you both.

    Btw. i have bought the manual (and the billing module) and used it during installation. For Debian 11, there is a lot to update in the manual regarding packages to install. If you're interested i can send you my notes i've made during setup, especially webserver was tricky to get fully running. Let me know if you are interested, so i will send you that.
     
    till and ahrasis like this.
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    The ISPConfig manual gets completely reworked incl. the outdated install guides. If it's not much additional work is needed from your side, then it would be nice if you could send me the notes to dev [at] ispconfig [dot] org. The 'new' way to install ISPConfig is the auto-installer, you can also find a guide on installing a multiserver system using the auto-installer here:

    https://www.howtoforge.com/tutorial/ispconfig-multiserver-setup-debian-ubuntu/

    the title says Debian 10, but as the installer script supports Debian 10 and 11, it should work on Debian 11 as well.
     

Share This Page