diff options
author | Omar Polo <op@omarpolo.com> | 2022-01-01 17:08:39 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2022-01-01 17:08:39 +0000 |
commit | 7bdcc91ec70ddde092ac5d7b4f75d54915e7b221 (patch) | |
tree | 94066bd47c57b6610ae184e0e6c9b6a32cc440ad /parse.y | |
parent | bd5f79542cf6491ed9e30bca926286e3b9e2600c (diff) |
simplify the proxying code
it doesn't make any sense to keep the proxying info per-location:
proxying only one per-vhost. It can't work differently, it doesn't make
sense anyway.
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 91 |
1 files changed, 48 insertions, 43 deletions
@@ -278,9 +278,57 @@ servopt : ALIAS string { | PARAM string '=' string { add_param($2, $4, 0); } + | proxy | locopt ; +proxy : PROXY proxy_opt + | PROXY '{' optnl proxy_opts '}' + ; + +proxy_opts : /* empty */ + | proxy_opts proxy_opt optnl + ; + +proxy_opt : CERT string { + struct proxy *p = &host->proxy; + + only_once(p->cert, "proxy cert"); + ensure_absolute_path($2); + p->cert = tls_load_file($2, &p->certlen, NULL); + if (p->cert == NULL) + yyerror("can't load cert %s", $2); + } + | KEY string { + struct proxy *p = &host->proxy; + + only_once(p->key, "proxy key"); + ensure_absolute_path($2); + p->key = tls_load_file($2, &p->keylen, NULL); + if (p->key == NULL) + yyerror("can't load key %s", $2); + } + | RELAY_TO string { + char *at; + const char *errstr; + struct proxy *p = &host->proxy; + + only_once(p->host, "proxy relay-to"); + p->host = $2; + + if ((at = strchr($2, ':')) != NULL) { + *at++ = '\0'; + p->port = at; + } else + p->port = "1965"; + + strtonum(p->port, 1, UINT16_MAX, &errstr); + if (errstr != NULL) + yyerror("proxy port is %s: %s", errstr, + p->port); + } + ; + locations : /* empty */ | locations location optnl ; @@ -330,7 +378,6 @@ locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; } loc->lang = $2; } | LOG bool { loc->disable_log = !$2; } - | proxy | REQUIRE CLIENT CA string { only_once(loc->reqca, "require client ca"); ensure_absolute_path($4); @@ -345,48 +392,6 @@ 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 : CERT string { - only_once(loc->proxy_cert, "proxy cert"); - ensure_absolute_path($2); - loc->proxy_cert = tls_load_file($2, &loc->proxy_cert_len, NULL); - if (loc->proxy_cert == NULL) - yyerror("can't load cert %s", $2); - } - | KEY string { - only_once(loc->proxy_key, "proxy key"); - ensure_absolute_path($2); - loc->proxy_key = tls_load_file($2, &loc->proxy_key_len, NULL); - if (loc->proxy_key == NULL) - yyerror("can't load key %s", $2); - } - | 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); |