How to set the Virtual Server Details, default IP address to ANY and port to 8080

Hi Guys,

I am running Varnish in front of Apache on one Virtualmin GPL server and I was wondering if it were possible to set the defaults for new Virtual Servers so that: 1. The default IP address is ANY and 2. The default port is 8080

See https://img.skitch.com/20120131-fbg9t6ykwiuyxnb3m5qdn7w3xu.jpg

Default IP Address ANY: If a new Virtual Server is created and the IP Address is specified (ie. not ANY) then it will add an entry to Apache httpd.conf which forces Apache to bind to that IP Address on Port 80.

Apache will then not re-start because Varnish is already bound to Port 80 on that IP Address.

Default Port 8080: Require this for same reason above.

Any help much appreciated!

Status: 
Closed (fixed)

Comments

You only really need to switch to port 8080, right? That would avoid the port clash, and then the IP doesn't matter ..

If so, you can set the default port at System Settings -> Server Templates -> Default settings -> Apache website -> Port number for virtual hosts.

Hi Jamie,

You only really need to switch to port 8080, right?

You'd think so, but no. If the IP address is set then an entry is automatically added to Apache httpd.conf which forces Apache to bind to that IP Address on Port 80.

Apache then does not restart. That's a problem.

Is it adding a Listen line for port 80, even after you change the default port to 8080 ? Virtualmin should only be adding a line like Listen 1.2.3.4:8080

Yes, that's exactly what it does.

See below, the last line was inserted by Virtualmin when the new Virtual Server was created and the IP address was set but the Port was set to 8080.

From httpd.conf

Listen *:8080
Listen *:4430
Listen 185.177.121.217:80

Which then causes Apache to not restart, as it clashes with Varnish.

So to fix, I jump in and update httpd.conf like so:

Listen *:8080
Listen *:4430
# Listen 185.177.121.217:80

Apache restarts OK then.

Does the <virtualhost> block for the domain get the right port (8080) ?

It adds the following to httpd.conf

<VirtualHost 185.177.121.217:8080>

Whereas I want it to add:

<VirtualHost *:8080>

I assume using the IP would be fine, as long as it was creating a Listen directive which the correct port?

Which virtualmin version are you using these? From looking at the code for the latest release, I can't see how it could be creating a Listen directive with the wrong port, but still creating a virtualhost with the right one..

Actually, I've just tested it again and the problem is the IP address being set for the Virtualhost.

The Port is being correctly set to Port 8080 and NO extra Listen directive is being added to Apache httpd.conf - so all good there. So forget what I said before - very likely due to me panicking about and trying various things to get Apache back up!

The problem is this new virtual host has a specific IP binding. <VirtualHost 185.177.121.217:8080>

But because we are using Varnish, the IP address of Varnish connecting to Apache is NEVER 185.177.121.217. It is actually 127.0.0.1 - on the same server.

So any Virtual Hosts with IP 185.177.121.217 will never work.

So I've been trying to get Virtualmin to create a Virtual Host with a 127.0.0.1, here is what I have tried, see https://img.skitch.com/20120131-q61t3ygpjrf1pwkcbfwyejs9j4.jpg

But have had no success.

So if I could get Virtualmin to create new Virtual Hosts like so: <VirtualHost *:8080> OR possibly <VirtualHost 127.0.0.1:8080>

That would solve the problem, no?

Or another solution would be to change Varnish to always connect using 185.177.121.217 instead of 127.0.0.1

I'll try that out.

Success!

Have changed Varnish to always connect using 185.177.121.217 instead of 127.0.0.1

And updated all the Apache Virtual Hosts to use the IP 185.177.121.217, which is the default assigned by Virtualmin.

Created a few new Apache Virtual Hosts and it is working.

So the problem really was of my own doing. Bad Varnish configuration. Stupid me!

Thanks for your time and listening.

Cool, glad you got it working ..