Discussion:
[Proftpd-user] Wildcard support for virtual hosts?
David Ordal
2009-03-13 04:45:06 UTC
Permalink
Anybody know if it's possible to have wildcards in <VirtualHost> directives?
So something like <VirtualHost *> instead of <VirtualHost 1.2.3.4>, which
would then bind to any IP address on the machine?

I have multiple servers running proftpd, and am trying to make a unified
config for all of them, but can't do it unless I can tell them to bind to
their own IP address, not the one I listed in the config.

D
TJ Saunders
2009-03-13 16:12:05 UTC
Permalink
Post by David Ordal
Anybody know if it's possible to have wildcards in <VirtualHost> directives?
So something like <VirtualHost *> instead of <VirtualHost 1.2.3.4>, which
would then bind to any IP address on the machine?
You don't need this; proftpd uses a wildcard socket by default. In fact,
you have to explicitly configure proftpd to use a socket per IP
address/port combination via "SocketBindTight on"; see:

http://www.proftpd.org/docs/howto/Vhost.html

Cheers,
TJ

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reach high, for stars lie hidden in your soul.
Dream deep, for every dream precedes the goal.

-Ralph Vaull Starr

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Ordal
2009-03-13 17:36:43 UTC
Permalink
You don't need this; proftpd uses a wildcard socket by default. In fact,
you have to explicitly configure proftpd to use a socket per IP
address/port combination via "SocketBindTight on";
OK, this is more complicated than I first thought:

If I just put in <VirtualHost>, I get:
Starting proftpd.
- Fatal: <VirtualHost>: wrong number of parameters on line 165 of
'/usr/local/etc/proftpd.conf'

So I have to put _something_ in... So I put 0.0.0.0:
<VirtualHost 0.0.0.0>

Now the problem is that proftpd thinks my host name is 0.0.0.0, so when I
use:
SQLUserWhereClause "server_name = '%V'"
it expands to
server_name = '0.0.0.0'
which doesn't match in my database.

If I do
<VirtualHost 127.0.0.1>
It looks up that IP in /etc/hosts file, and gives me
server_name = 'localhost.localdomain'

What I need is some format for the VirtualHost directive that doesn't
require an IP or hostname, and then uses whatever IP the connection was made
on to do the hostname lookup for %V

Thoughts?

D
TJ Saunders
2009-03-13 19:46:17 UTC
Permalink
Post by David Ordal
What I need is some format for the VirtualHost directive that doesn't
require an IP or hostname, and then uses whatever IP the connection was made
on to do the hostname lookup for %V
Consider this:

<VirtualHost 1.2.3.4>
ServerName foo
...
</VirtualHost>

<VirtualHost 5.6.7.8>
ServerName bar
...
</VirtualHost>

The ServerName (%V) is already determined by the vhost configuration that
proftpd chooses to handle the incoming connection (based on the IP address
to which the client connected); I'm not sure why you need to look up the
ServerName based on the hostname of anything.

If you're trying to have the same <VirtualHost> configuration apply to all
of your connections, that you're using a <VirtualHost> for the wrong
purpose. You could simply place all of that configuration in the "server
config" context (i.e. outside of any <Global> or <VirtualHost> sections),
and place "DefaultServer on" in that "server config" section. The
"DefaultServer on" tells proftpd to use that config to handle a
connection, when no other matching <VirtualHost> section is found for the
incoming connection. This way, _all_ connections get your "server config"
configuration, regardless of the IP address to which they connected.

If you're running a proftpd older than 1.3.2, you might be encountering:

http://bugs.proftod.org/show_bug.cgi?id=3149

TJ

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The reasonable man adapts himself to the world: the unreasonable man
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man.

-George Bernard Shaw

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TJ Saunders
2009-03-17 19:06:50 UTC
Permalink
Post by David Ordal
Anybody know if it's possible to have wildcards in <VirtualHost> directives?
So something like <VirtualHost *> instead of <VirtualHost 1.2.3.4>, which
would then bind to any IP address on the machine?
For the list's reference, this is now supported in CVS, using:

<VirtualHost 0.0.0.0>

See:

http://bugs.proftpd.org/show_bug.cgi?id=2680

Cheers,
TJ

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To See a World in a Grain of Sand,
And a Heaven in a Wild Flower,
Hold Infinity in the palm of your hand,
And Eternity in an hour.

-William Blake

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Continue reading on narkive:
Loading...