HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Feature Requests (http://www.howtoforge.com/forums/forumdisplay.php?f=31)
-   -   Choose listen port of a VirtualHost or overall apache listen port (http://www.howtoforge.com/forums/showthread.php?t=57924)

Estopero 13th July 2012 12:49

Choose listen port of a VirtualHost or overall apache listen port
 
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:

/usr/local/ispconfig/server/conf/vhost.conf.master

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,
Tomás

tio289 25th July 2012 13:39

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/plugins-availableapache2_plugin.inc.php 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.

tio289 25th July 2012 13:41

Quote:

Originally Posted by Estopero (Post 282024)
...to get listen in a different port is needed to change the default conf template at:

/usr/local/ispconfig/server/conf/vhost.conf.master

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.

till 25th July 2012 14:14

Quote:

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.
You are wrong as you can select between ssl and non ssl hosts in the template. Check the if conditions.

tio289 25th July 2012 14:29

I have this in vhosts.conf

Code:

<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

Code:

<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.

till 25th July 2012 14:42

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:

Code:

<tmpl_loop name="vhosts">
<tmpl_if name='ssl_enabled'>
<VirtualHost {tmpl_var name='ip_address'}:81>
<tmpl_else>
<VirtualHost {tmpl_var name='ip_address'}:82>
</tmpl_if>


tio289 25th July 2012 14:44

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

till 25th July 2012 15:09

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 ;)

Estopero 28th August 2012 13:32

Quote:

Originally Posted by till (Post 282727)
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 ;)

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):

Quote:

<tmpl_loop name="vhosts">
<tmpl_if name='ssl_enabled'>
<VirtualHost {tmpl_var name='ip_address'}:443>
<tmpl_else>
<VirtualHost {tmpl_var name='ip_address'}:81>
</tmpl_if>
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 =)

Thanks


All times are GMT +2. The time now is 11:00.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.