move proxy sub-options to their own rule and allow grouping with { ... }

This commit is contained in:
Omar Polo 2022-01-01 16:33:40 +00:00
parent cc1c8f548c
commit da2185f37f
1 changed files with 29 additions and 18 deletions

47
parse.y
View File

@ -330,24 +330,7 @@ locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; }
loc->lang = $2;
}
| LOG bool { loc->disable_log = !$2; }
| PROXY RELAY_TO string {
char *at;
const char *errstr;
only_once(loc->proxy_host, "proxy relay-to");
loc->proxy_host = $3;
if ((at = strchr($3, ':')) != NULL) {
*at++ = '\0';
loc->proxy_port = at;
} else
loc->proxy_port = "1965";
strtonum(loc->proxy_port, 1, UINT16_MAX, &errstr);
if (errstr != NULL)
yyerror("proxy port is %s: %s", errstr,
loc->proxy_port);
}
| proxy
| REQUIRE CLIENT CA string {
only_once(loc->reqca, "require client ca");
ensure_absolute_path($4);
@ -362,6 +345,34 @@ locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; }
| STRIP NUM { loc->strip = check_strip_no($2); }
;
proxy : PROXY proxy_opt
| PROXY '{' optnl proxy_opts '}'
;
proxy_opts : /* empty */
| proxy_opts proxy_opt optnl
;
proxy_opt : RELAY_TO string {
char *at;
const char *errstr;
only_once(loc->proxy_host, "proxy relay-to");
loc->proxy_host = $2;
if ((at = strchr($2, ':')) != NULL) {
*at++ = '\0';
loc->proxy_port = at;
} else
loc->proxy_port = "1965";
strtonum(loc->proxy_port, 1, UINT16_MAX, &errstr);
if (errstr != NULL)
yyerror("proxy port is %s: %s", errstr,
loc->proxy_port);
}
;
fastcgi : SPAWN string {
only_oncei(loc->fcgi, "fastcgi");
loc->fcgi = fastcgi_conf(NULL, NULL, $2);