This command cannot be used if the reference <acl> is a name also used with
a map. In this case, the "add map" command must be used instead.
-add backend <name> from <defproxy> [ EXPERIMENTAL ]
+add backend <name> from <defproxy> [mode <mode>] [ EXPERIMENTAL ]
Instantiate a new backend proxy with the name <name>.
Only TCP or HTTP proxies can be created. All of the settings are inherited
- from <defproxy> default proxy instance. Servers can be added via the command
- "add server". The backend is initialized in the unpublished state. Once
- considered ready for traffic, use "publish backend" to expose the newly
- created instance.
+ from <defproxy> default proxy instance. By default, it is mandatory to
+ specify the backend mode via the argument of the same name, unless <defproxy>
+ already defines it explicitely.
+
+ Servers can be added via the command "add server". The backend is initialized
+ in the unpublished state. Once considered ready for traffic, use "publish
+ backend" to expose the newly created instance.
This command is restricted and can only be issued on sockets configured for
level "admin". Moreover, this feature is still considered in development so it
/* Proxy flags */
#define PR_FL_DISABLED 0x01 /* The proxy was disabled in the configuration (not at runtime) */
#define PR_FL_STOPPED 0x02 /* The proxy was stopped */
-/* 0x04 unused */
+#define PR_FL_DEF_EXPLICIT_MODE 0x04 /* Proxy mode is explicitely defined - only used for defaults instance */
#define PR_FL_EXPLICIT_REF 0x08 /* The default proxy is explicitly referenced by another proxy */
#define PR_FL_IMPLICIT_REF 0x10 /* The default proxy is implicitly referenced by another proxy */
#define PR_FL_PAUSED 0x20 /* The proxy was paused at run time (reversible) */
}
curproxy->mode = mode;
+ if (curproxy->cap & PR_CAP_DEF)
+ curproxy->flags |= PR_FL_DEF_EXPLICIT_MODE;
}
else if (strcmp(args[0], "id") == 0) {
struct proxy *conflict;
struct proxy *px, *defpx;
const char *be_name, *def_name, *err;
char *msg = NULL;
+ enum pr_mode mode = 0;
usermsgs_clr("CLI");
return 1;
}
+ /* Parse optional arguments */
+ args += 2;
+ while (*args[1]) {
+ /* "mode" */
+ if (*args[2] && !mode && strcmp(args[1], "mode") == 0) {
+ mode = str_to_proxy_mode(args[2]);
+ if (mode == PR_MODES) {
+ cli_err(appctx, "Unknown proxy mode.\n");
+ return 1;
+ }
+ if (mode != PR_MODE_TCP && mode != PR_MODE_HTTP) {
+ cli_err(appctx, "Dynamic backends are compatible with only TCP or HTTP mode.\n");
+ return 1;
+ }
+ }
+ /* unknown, malformed or duplicate argument */
+ else {
+ cli_err(appctx, "Usage: add backend <name> from <defproxy> [mode <px_mode>].\n");
+ return 1;
+ }
+
+ args += 2;
+ }
+
defpx = proxy_find_by_name(def_name, PR_CAP_DEF, 0);
if (!defpx) {
cli_dynerr(appctx, memprintf(&msg, "Cannot find default proxy '%s'.\n", def_name));
return 1;
}
+ if (!(defpx->flags & PR_FL_DEF_EXPLICIT_MODE) && !mode) {
+ cli_dynerr(appctx, memprintf(&msg, "Mode is required as '%s' default proxy does not explicitely defines it.\n", def_name));
+ return 1;
+ }
thread_isolate();