static char * ngx_http_session_sticky_hide_cookie(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_ss_loc_conf_t *slcf = conf; size_t add; ngx_str_t *value; ngx_url_t u; value = (ngx_str_t *) cf->args->elts; if (ngx_strncmp(value[0].data, "session_sticky_header", 21) == 0) { ngx_conf_deprecated(cf, &ngx_conf_deprecated_session_sticky_header, NULL); } if (ngx_strncmp(value[1].data, "upstream=", 9) == 0) { add = 9; ngx_memzero(&u, sizeof(ngx_url_t)); u.url.len = value[1].len - add; u.url.data = value[1].data + add; u.uri_part = 1; u.no_resolve = 1; slcf->uscf = ngx_http_upstream_add(cf, &u, 0); if (slcf->uscf == NULL) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid upstream name"); return NGX_CONF_ERROR; } return NGX_CONF_OK; } ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid argument of \"%V\"", &value[1]); return NGX_CONF_ERROR; }
static char * ngx_http_limit_zone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { syslog(LOG_INFO, "[%s:%s:%d]", __FILE__, __func__, __LINE__); ssize_t n; ngx_str_t *value; ngx_shm_zone_t *shm_zone; ngx_http_limit_conn_ctx_t *ctx; ngx_conf_deprecated(cf, &ngx_conf_deprecated_limit_zone, NULL); value = cf->args->elts; if (value[2].data[0] != '$') { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid variable name \"%V\"", &value[2]); return NGX_CONF_ERROR; } value[2].len--; value[2].data++; ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_limit_conn_ctx_t)); if (ctx == NULL) { return NGX_CONF_ERROR; } ctx->index = ngx_http_get_variable_index(cf, &value[2]); if (ctx->index == NGX_ERROR) { return NGX_CONF_ERROR; } ctx->var = value[2]; n = ngx_parse_size(&value[3]); if (n == NGX_ERROR) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid size of limit_zone \"%V\"", &value[3]); return NGX_CONF_ERROR; } if (n < (ngx_int_t) (8 * ngx_pagesize)) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "limit_zone \"%V\" is too small", &value[1]); return NGX_CONF_ERROR; } shm_zone = ngx_shared_memory_add(cf, &value[1], n, &ngx_http_limit_conn_module); if (shm_zone == NULL) { return NGX_CONF_ERROR; } if (shm_zone->data) { ctx = shm_zone->data; ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "limit_zone \"%V\" is already bound to variable \"%V\"", &value[1], &ctx->var); return NGX_CONF_ERROR; } shm_zone->init = ngx_http_limit_conn_init_zone; shm_zone->data = ctx; return NGX_CONF_OK; }