Choose listen port of a VirtualHost or overall apache listen port

Discussion in 'Feature Requests' started by Estopero, Jul 13, 2012.

  1. Estopero

    Estopero New Member

    I've realized that when a Server IP is added to ISPConfig, a list of listen ports can be choosen, and a NameVirtualHost IP:port line is added to the apache config at sites-available/ispconfig.conf.

    However there is no way to choose the listen port of apache server or of a site/virtualhost, only the IP can be choosen and to get listen in a different port is needed to change the default conf template at:


    This is so weird, because in the template there is a "port" variable but I haven't found a way to change it in the ISPConfig panel.

    It would be cool can choose a different port for each virtualhost, this is very usefull when a reverse proxy like varnish is used in a machine with dinamic and static content with only 1 IP. And seems that the internal logic is almost implemented in ISPConfig to get this.

    Thank you,
  2. tio289

    tio289 Member

    Hello, I use reverse proxy too. Apache is listening on port 82. I added this port to System => IP Addresses. ISPConfig use this config only in sites-available/ispconfig.conf when defining NameVirtualhosts.

    So I looked at plugins, specific /usr/local/ispconfig/server/ and I found that ports are hard coded in this file. So I edit hardcoded ports 80 to 82 and resync sites. Its on 4 places together. If I update ispconfig I must edit this file again.

    Will be better, if this plugin get right ports from db instead of hardcode it.
    Last edited: Jul 25, 2012
  3. tio289

    tio289 Member

    this is bad solution, because this template is for SSL vhosts too, so if you hardcode port for non-ssl vhosts, ssl vhost created by ispconfig will use same port = fail.
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    You are wrong as you can select between ssl and non ssl hosts in the template. Check the if conditions.
  5. tio289

    tio289 Member

    I have this in vhosts.conf

    <tmpl_loop name="vhosts">
    <VirtualHost {tmpl_var name='ip_address'}:{tmpl_var name='port'}>
    so ip and port is given from var, and if site has ssl on, loop has 2 entries. So if he hardcode port to this

    <tmpl_loop name="vhosts">
    <VirtualHost {tmpl_var name='ip_address'}:82>
    ssl will be same port as non-ssl.

    in the past version of ispconfig, was in vhost.conf two virtualhosts. One for non-ssl and one fo ssl. Now, as we can see, is there loop.
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Your configuration is wrong. As you can see in the template,all ssl specfic instructions are wrapped in a if stetement, so you can select between ssl and non ssl easily. The correct configuration is:

    <tmpl_loop name="vhosts">
    <tmpl_if name='ssl_enabled'>
    <VirtualHost {tmpl_var name='ip_address'}:81>
    <VirtualHost {tmpl_var name='ip_address'}:82>
  7. tio289

    tio289 Member

    I have latest ispconfig and I doesnt change anything in this file.
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    If you want to use customports, then you have to configure them in the vhost file like I explained above and like it is explained in other threads here in the forum as well. If you dont configure your custom ports, then it wont work of course ;)
  9. Estopero

    Estopero New Member

    Till, my master template looks also like tio289. But I did the change that you said and it worked for ssl/non-ssl sites thanks :), now is something like this (I needed to re-save the vhosts):

    However, really to implement a custom port by vhost in the Control Panel is a too hard task?

    I think that modify templates should be an "exception" action, what happens with that templates when ispconfig is upgraded? Would be needed to re-apply the changes to the templates? Also exists the problem with choose a different port/IP for different vhosts (maybe only some vhosts run with a reverse-proxy and not all of them)

    I understand that you may have other priorities but don't forget this please =)

    Last edited: Aug 28, 2012

Share This Page