diff --git a/doc/nghttpx.h2r b/doc/nghttpx.h2r index 4def0b70..4e598f8b 100644 --- a/doc/nghttpx.h2r +++ b/doc/nghttpx.h2r @@ -300,15 +300,16 @@ HTTP variables, like authority or request path, and even return custom response without forwarding request to backend servers. There are 2 levels of mruby script invocations: global and -per-backend. The global mruby script is set by :option:`--mruby-file` -option and is called for all requests. The per-backend mruby script +per-pattern. The global mruby script is set by :option:`--mruby-file` +option and is called for all requests. The per-pattern mruby script is set by "mruby" parameter in :option:`-b` option. It is invoked for -a request which is forwarded to the particular backend. The order of -hook invocation is: global request phase hook, per-backend request -phase hook, per-backend response phase hook, and finally global -response phase hook. If a hook returns a response, any later hooks -are not invoked. The global request hook is invoked before selecting -backend, and changing request path may affect the backend selection. +a request which matches the particular pattern. The order of hook +invocation is: global request phase hook, per-pattern request phase +hook, per-pattern response phase hook, and finally global response +phase hook. If a hook returns a response, any later hooks are not +invoked. The global request hook is invoked before the pattern +matching is made and changing request path may affect the pattern +matching. The all mruby script will be evaluated once per thread on startup, and it must instantiate object and evaluate it as the return value (e.g., diff --git a/gennghttpxfun.py b/gennghttpxfun.py index 8a2ecbb2..425ed74a 100755 --- a/gennghttpxfun.py +++ b/gennghttpxfun.py @@ -169,7 +169,7 @@ OPTIONS = [ "ocsp-startup", "no-verify-ocsp", "verify-client-tolerate-expired", - "ignore-per-backend-mruby-error", + "ignore-per-pattern-mruby-error", ] LOGVARS = [ diff --git a/src/shrpx.cc b/src/shrpx.cc index adf45e5d..be867a10 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -1829,8 +1829,9 @@ Connections: field on TLS encrypted connection. "mruby=" parameter specifies a path to mruby - script file which is invoked when this backend is - selected. + script file which is invoked when this pattern is + matched. All backends which share the same pattern must + have the same mruby path. Since ";" and ":" are used as delimiter, must not contain these characters. Since ";" has special @@ -2754,10 +2755,10 @@ Process: Scripting: --mruby-file= Set mruby script file - --ignore-per-backend-mruby-error - Ignore mruby compile error for per-backend mruby script + --ignore-per-pattern-mruby-error + Ignore mruby compile error for per-pattern mruby script file. If error occurred, it is treated as if no mruby - file were specified for the backend. + file were specified for the pattern. Misc: --conf= @@ -3433,7 +3434,7 @@ int main(int argc, char **argv) { {SHRPX_OPT_SINGLE_PROCESS.c_str(), no_argument, &flag, 159}, {SHRPX_OPT_VERIFY_CLIENT_TOLERATE_EXPIRED.c_str(), no_argument, &flag, 160}, - {SHRPX_OPT_IGNORE_PER_BACKEND_MRUBY_ERROR.c_str(), no_argument, &flag, + {SHRPX_OPT_IGNORE_PER_PATTERN_MRUBY_ERROR.c_str(), no_argument, &flag, 161}, {nullptr, 0, nullptr, 0}}; @@ -4202,8 +4203,8 @@ int main(int argc, char **argv) { StringRef::from_lit("yes")); break; case 161: - // --ignore-per-backend-mruby-error - cmdcfgs.emplace_back(SHRPX_OPT_IGNORE_PER_BACKEND_MRUBY_ERROR, + // --ignore-per-pattern-mruby-error + cmdcfgs.emplace_back(SHRPX_OPT_IGNORE_PER_PATTERN_MRUBY_ERROR, StringRef::from_lit("yes")); break; default: diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index a00a3587..503007c8 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -2199,8 +2199,8 @@ int option_lookup_token(const char *name, size_t namelen) { } break; case 'r': - if (util::strieq_l("ignore-per-backend-mruby-erro", name, 29)) { - return SHRPX_OPTID_IGNORE_PER_BACKEND_MRUBY_ERROR; + if (util::strieq_l("ignore-per-pattern-mruby-erro", name, 29)) { + return SHRPX_OPTID_IGNORE_PER_PATTERN_MRUBY_ERROR; } if (util::strieq_l("strip-incoming-x-forwarded-fo", name, 29)) { return SHRPX_OPTID_STRIP_INCOMING_X_FORWARDED_FOR; @@ -3587,8 +3587,8 @@ int parse_config(Config *config, int optid, const StringRef &opt, config->tls.client_verify.tolerate_expired = util::strieq_l("yes", optarg); return 0; - case SHRPX_OPTID_IGNORE_PER_BACKEND_MRUBY_ERROR: - config->ignore_per_backend_mruby_error = util::strieq_l("yes", optarg); + case SHRPX_OPTID_IGNORE_PER_PATTERN_MRUBY_ERROR: + config->ignore_per_pattern_mruby_error = util::strieq_l("yes", optarg); return 0; case SHRPX_OPTID_CONF: @@ -3885,10 +3885,10 @@ int configure_downstream_group(Config *config, bool http2_proxy, // Try compile mruby script and catch compile error early. if (!g.mruby_file.empty()) { if (mruby::create_mruby_context(g.mruby_file) == nullptr) { - LOG(config->ignore_per_backend_mruby_error ? ERROR : FATAL) + LOG(config->ignore_per_pattern_mruby_error ? ERROR : FATAL) << "backend: Could not compile mruby flie for pattern " << g.pattern; - if (!config->ignore_per_backend_mruby_error) { + if (!config->ignore_per_pattern_mruby_error) { return -1; } g.mruby_file = StringRef{}; diff --git a/src/shrpx_config.h b/src/shrpx_config.h index 33b08b83..d4cb4d9d 100644 --- a/src/shrpx_config.h +++ b/src/shrpx_config.h @@ -345,8 +345,8 @@ constexpr auto SHRPX_OPT_OCSP_STARTUP = StringRef::from_lit("ocsp-startup"); constexpr auto SHRPX_OPT_NO_VERIFY_OCSP = StringRef::from_lit("no-verify-ocsp"); constexpr auto SHRPX_OPT_VERIFY_CLIENT_TOLERATE_EXPIRED = StringRef::from_lit("verify-client-tolerate-expired"); -constexpr auto SHRPX_OPT_IGNORE_PER_BACKEND_MRUBY_ERROR = - StringRef::from_lit("ignore-per-backend-mruby-error"); +constexpr auto SHRPX_OPT_IGNORE_PER_PATTERN_MRUBY_ERROR = + StringRef::from_lit("ignore-per-pattern-mruby-error"); constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8; @@ -918,7 +918,7 @@ struct Config { http2_proxy{false}, single_process{false}, single_thread{false}, - ignore_per_backend_mruby_error{false}, + ignore_per_pattern_mruby_error{false}, ev_loop_flags{0} {} ~Config(); @@ -963,8 +963,8 @@ struct Config { // handling is omitted. bool single_process; bool single_thread; - // Ignore mruby compile error for per-backend mruby script. - bool ignore_per_backend_mruby_error; + // Ignore mruby compile error for per-pattern mruby script. + bool ignore_per_pattern_mruby_error; // flags passed to ev_default_loop() and ev_loop_new() int ev_loop_flags; }; @@ -1069,7 +1069,7 @@ enum { SHRPX_OPTID_HTTP2_MAX_CONCURRENT_STREAMS, SHRPX_OPTID_HTTP2_NO_COOKIE_CRUMBLING, SHRPX_OPTID_HTTP2_PROXY, - SHRPX_OPTID_IGNORE_PER_BACKEND_MRUBY_ERROR, + SHRPX_OPTID_IGNORE_PER_PATTERN_MRUBY_ERROR, SHRPX_OPTID_INCLUDE, SHRPX_OPTID_INSECURE, SHRPX_OPTID_LISTENER_DISABLE_TIMEOUT,