aboutsummaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-07-23 18:45:05 +0000
committerOmar Polo <op@omarpolo.com>2023-07-23 18:45:05 +0000
commita1ba9650a9f0cc0d9e70800d71769d32f927b939 (patch)
tree4ce8a9b5e4cd3aff8a41d4cd67c15f7c07774b17 /parse.y
parentf36ba9be59c1b60aff4b9663f49d8656800afa00 (diff)
revamp fastcgi configuration: make it per-location
this revamps the syntax in the configuration to better match httpd(8) (and in general be less weird) and to allow per-location fastcgi configurations. the bare `param' is now deprecated, but for compatibility it acts like `fastcgi param' would do now. Same story for `fastcgi <pathÂ>'.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y55
1 files changed, 38 insertions, 17 deletions
diff --git a/parse.y b/parse.y
index 5a72bf4..2dcb4bc 100644
--- a/parse.y
+++ b/parse.y
@@ -133,7 +133,7 @@ typedef struct {
%token OCSP OFF ON
%token PARAM PORT PREFORK PROTO PROTOCOLS PROXY
%token RELAY_TO REQUIRE RETURN ROOT
-%token SERVER SNI STRIP
+%token SERVER SNI SOCKET STRIP
%token TCP TOEXT TYPE TYPES
%token USE_TLS USER
%token VERIFYNAME
@@ -326,6 +326,8 @@ servopt : ALIAS string {
host->ocsp_path = $2;
}
| PARAM string '=' string {
+ yywarn("the top-level `param' directive is deprecated."
+ " Please use `fastcgi { param ... }`");
add_param($2, $4);
}
| LISTEN ON listen_addr {
@@ -465,7 +467,7 @@ locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; }
sizeof(loc->default_mime));
free($3);
}
- | FASTCGI fastcgi
+ | fastcgi
| INDEX string {
(void) strlcpy(loc->index, $2, sizeof(loc->index));
free($2);
@@ -487,26 +489,44 @@ locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; }
| STRIP NUM { loc->strip = check_strip_no($2); }
;
-fastcgi : string {
- loc->fcgi = fastcgi_conf($1, NULL);
- free($1);
+fastcgi : FASTCGI '{' optnl fastcgiopts '}'
+ | FASTCGI fastcgiopt
+ | FASTCGI string {
+ yywarn("`fastcgi path' is deprecated. "
+ "Please use `fastcgi socket path' instead.");
+ loc->fcgi = fastcgi_conf($2, NULL);
+ free($2);
+ }
+ | error '}'
+ ;
+
+fastcgiopts : /* empty */
+ | fastcgiopts fastcgiopt optnl
+ ;
+
+fastcgiopt : PARAM string '=' string {
+ add_param($2, $4);
}
- | TCP string PORT NUM {
+ | SOCKET string {
+ loc->fcgi = fastcgi_conf($2, NULL);
+ free($2);
+ }
+ | SOCKET TCP string PORT NUM {
char *c;
- if (asprintf(&c, "%d", $4) == -1)
+
+ if (asprintf(&c, "%d", $5) == -1)
fatal("asprintf");
- loc->fcgi = fastcgi_conf($2, c);
- free($2);
+ loc->fcgi = fastcgi_conf($3, c);
+ free($3);
free(c);
}
- | TCP string {
- loc->fcgi = fastcgi_conf($2, "9000");
- free($2);
+ | SOCKET TCP string {
+ loc->fcgi = fastcgi_conf($3, "9000");
}
- | TCP string PORT string {
- loc->fcgi = fastcgi_conf($2, $4);
- free($2);
- free($4);
+ | SOCKET TCP string PORT string {
+ loc->fcgi = fastcgi_conf($3, $5);
+ free($3);
+ free($5);
}
;
@@ -586,6 +606,7 @@ static const struct keyword {
{"root", ROOT},
{"server", SERVER},
{"sni", SNI},
+ {"socket", SOCKET},
{"strip", STRIP},
{"tcp", TCP},
{"to-ext", TOEXT},
@@ -1183,7 +1204,7 @@ void
add_param(char *name, char *val)
{
struct envlist *e;
- struct envhead *h = &host->params;
+ struct envhead *h = &loc->params;
e = xcalloc(1, sizeof(*e));
(void) strlcpy(e->name, name, sizeof(e->name));