On Thu, Jan 01, 2015 at 11:54:46PM -0500, Geoff Steckel wrote:
Is there any way todo the equivalent of:
server an.example.com
listen on 192.168.2.99
listen on 2001.fefe.1.1::99
??
It appears that the code in parse.y explicitly forbids this
and the data structures for a server don't *seem*
to have more than one slot for an address.
Is there another way to achieve this effect?
From one comment in the checkins, it looks like
server an.example.com
listen on 192.168.2.99
.
server an.example.com
listen on 2001.fefe.1.1::99
would work.
Duplicating the entire server description is
difficult to maintain.
Is someone planning to work in this area soon?
thanks
Geoff Steckel
I used include directives to avoid duplications (see previous reply)
but the following diff allows to add aliases and multiple listen
statements.
Reyk
Index: config.c
===
RCS file: /cvs/src/usr.sbin/httpd/config.c,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 config.c
--- config.c21 Dec 2014 00:54:49 - 1.26
+++ config.c3 Jan 2015 13:33:25 -
@@ -174,7 +174,9 @@ config_setserver(struct httpd *env, stru
if ((what CONFIG_SERVERS) == 0 || id == privsep_process)
continue;
- DPRINTF(%s: sending server \%s[%u]\ to %s fd %d, __func__,
+ DPRINTF(%s: sending %s \%s[%u]\ to %s fd %d, __func__,
+ (srv-srv_conf.flags SRVFLAG_LOCATION) ?
+ location : server,
srv-srv_conf.name, srv-srv_conf.id,
ps-ps_title[id], srv-srv_s);
Index: httpd.conf.5
===
RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
retrieving revision 1.40
diff -u -p -u -p -r1.40 httpd.conf.5
--- httpd.conf.528 Dec 2014 13:53:23 - 1.40
+++ httpd.conf.53 Jan 2015 13:33:25 -
@@ -135,6 +135,10 @@ must have a
.Ar name
and include one or more lines of the following syntax:
.Bl -tag -width Ds
+.It Ic alias Ar name
+Specify an additional alias
+.Ar name
+for this server.
.It Ic connection Ar option
Set the specified options and limits for HTTP connections.
Valid options are:
@@ -180,6 +184,7 @@ and defaults to
.Pa /run/slowcgi.sock .
.It Ic listen on Ar address Oo Ic tls Oc Ic port Ar number
Set the listen address and port.
+This statement can be specified multiple times.
.It Ic location Ar path Brq ...
Specify server configuration rules for a specific location.
The
@@ -391,6 +396,13 @@ If the same address is repeated multiple
statement,
the server will be matched based on the requested host name.
.Bd -literal -offset indent
+server www.example.com {
+ alias example.com
+ listen on * port 80
+ listen on * tls port 443
+ root /htdocs/www.example.com
+}
+
server www.a.example.com {
listen on 203.0.113.1 port 80
root /htdocs/www.a.example.com
Index: parse.y
===
RCS file: /cvs/src/usr.sbin/httpd/parse.y,v
retrieving revision 1.46
diff -u -p -u -p -r1.46 parse.y
--- parse.y 21 Dec 2014 00:54:49 - 1.46
+++ parse.y 3 Jan 2015 13:33:26 -
@@ -106,6 +106,8 @@ int host_if(const char *, struct addre
int host(const char *, struct addresslist *,
int, struct portrange *, const char *, int);
voidhost_free(struct addresslist *);
+struct server *server_inherit(struct server *, const char *,
+ struct server_config *);
int getservice(char *);
int is_if_in_group(const char *, const char *);
@@ -125,10 +127,10 @@ typedef struct {
%}
-%token ACCESS AUTO BACKLOG BODY BUFFER CERTIFICATE CHROOT CIPHERS COMMON
+%token ACCESS ALIAS AUTO BACKLOG BODY BUFFER CERTIFICATE CHROOT CIPHERS COMMON
%token COMBINED CONNECTION DIRECTORY ERR FCGI INDEX IP KEY LISTEN LOCATION
%token LOG LOGDIR MAXIMUM NO NODELAY ON PORT PREFORK REQUEST REQUESTS ROOT
-%token SACK SERVER SOCKET STYLE SYSLOG TCP TIMEOUT TLS TYPES
+%token SACK SERVER SOCKET STYLE SYSLOG TCP TIMEOUT TLS TYPES
%token ERROR INCLUDE
%token v.string STRING
%token v.number NUMBER
@@ -247,8 +249,14 @@ server : SERVER STRING {
srv_conf = srv-srv_conf;
SPLAY_INIT(srv-srv_clients);
+ TAILQ_INIT(srv-srv_hosts);
+
+ TAILQ_INSERT_TAIL(srv-srv_hosts, srv_conf, entry);
} '{' optnl serveropts_l '}'{
- struct server *s = NULL;
+ struct server *s = NULL, *sn;
+ struct server_config*a, *b;
+
+ srv_conf = srv-srv_conf;
TAILQ_FOREACH(s, conf-sc_servers, srv_entry) {
if