Changing ports without editing VHost template

Discussion in 'Plugins/Modules/Addons' started by manoaratefy, Jan 6, 2021.

  1. manoaratefy

    manoaratefy New Member

    Good morning,
    For better integration, I wish to edit vhost ports without adding custom vhost template in ISPConfig. So, I don't need to update by custom vhost template each time ISPConfig source code update its own. How can I achieve this?
     
    ahrasis likes this.
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    I'm afraid there's no other way currently.
     
    ahrasis likes this.
  3. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    If you're wishing to implement this feature, a few notes that might help are: you'll need to add a place under server config to specify which ports are to be used on a server, as well as whether it's an http or https port; you'll need to modify the apache and nginx server plugins to setup the respective web servers to listen on those ports; likely you'll want to specify which ports are available to a client to be able to use in their website settings, which could be modeled off how ip addrs behave (assigned to a client, or available to everyone or only to admin?); if there's only one http port and one https port available to a client, don't offer a selection, simply use those ports; and of course the vhost template files will need tweaked.

    Extra credit if you also check ports used by reverse proxies and ensure you can't use a port for the web server that's already in use. :)
     
    ahrasis likes this.
  4. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    You may already know that all website vhost files are updated to use the latest via rsync tool while system vhost files (apps and ispconfig) are updated via ISPConfig update.

    A simple script with sed command to find and replace, in your case the ports, in the event of vhost files are changed, monitored by incron or monit, would do. The script should warn you if there is any failure, so you can attend to it manually.

    Or simply run the script right after you run the script after ISPConfig update command "php -q update.php; yourscript;", so no need incron or monit, though you may forget about including the script, sometimes.

    If you need more than changing the ports, then the script will have to include more command as well.
     
  5. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    I would not do this for all vhosts. You could do this for the vhost.conf.master in /usr/local/ispconfig/server/conf/ and let it replace 80 with your custom port and 443 with your custom https port and monitor that with incron.
     
  6. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Same point but editing /conf/ directory files directly is not advisable, same as the vhost files, I leave that to the one who in needs of it to decide.

    I basically didn't mention about which files and in which folder to change but my best advise is still to use conf-custom and edit the files in there, in the event of ISPConfig update to achieve whatever you need.

    It is the way. ;)
     

Share This Page