mirror of
https://github.com/nginx/nginx.git
synced 2025-06-17 17:20:42 +08:00
server_name "" support
This commit is contained in:
parent
027095a77e
commit
b29426deb8
@ -220,6 +220,10 @@ ngx_hash_find_combined(ngx_hash_combined_t *hash, ngx_uint_t key, u_char *name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (hash->wc_head && hash->wc_head->hash.buckets) {
|
if (hash->wc_head && hash->wc_head->hash.buckets) {
|
||||||
value = ngx_hash_find_wc_head(hash->wc_head, name, len);
|
value = ngx_hash_find_wc_head(hash->wc_head, name, len);
|
||||||
|
|
||||||
|
@ -3094,17 +3094,24 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
ch = value[1].data[0];
|
ch = value[1].data[0];
|
||||||
|
|
||||||
if (cscf->server_name.data == NULL && value[1].len) {
|
if (cscf->server_name.data == NULL) {
|
||||||
name = value[1];
|
if (value[1].len) {
|
||||||
|
name = value[1];
|
||||||
|
|
||||||
if (ch == '.') {
|
if (ch == '.') {
|
||||||
name.len--;
|
name.len--;
|
||||||
name.data++;
|
name.data++;
|
||||||
}
|
}
|
||||||
|
|
||||||
cscf->server_name.len = name.len;
|
cscf->server_name.len = name.len;
|
||||||
cscf->server_name.data = ngx_pstrdup(cf->pool, &name);
|
cscf->server_name.data = ngx_pstrdup(cf->pool, &name);
|
||||||
if (cscf->server_name.data == NULL) {
|
if (cscf->server_name.data == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"the first server name must not be empty");
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3113,8 +3120,7 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
ch = value[i].data[0];
|
ch = value[i].data[0];
|
||||||
|
|
||||||
if (value[i].len == 0
|
if ((ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
|
||||||
|| (ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
|
|
||||||
|| (ch == '.' && value[i].len < 2))
|
|| (ch == '.' && value[i].len < 2))
|
||||||
{
|
{
|
||||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
@ -571,6 +571,7 @@ ngx_http_ssl_handshake_handler(ngx_connection_t *c)
|
|||||||
int
|
int
|
||||||
ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg)
|
ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg)
|
||||||
{
|
{
|
||||||
|
size_t len;
|
||||||
const char *servername;
|
const char *servername;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
ngx_http_request_t *r;
|
ngx_http_request_t *r;
|
||||||
@ -587,12 +588,15 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg)
|
|||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||||
"SSL server name: \"%s\"", servername);
|
"SSL server name: \"%s\"", servername);
|
||||||
|
|
||||||
|
len = ngx_strlen(servername);
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
return SSL_TLSEXT_ERR_NOACK;
|
||||||
|
}
|
||||||
|
|
||||||
r = c->data;
|
r = c->data;
|
||||||
|
|
||||||
if (ngx_http_find_virtual_server(r, (u_char *) servername,
|
if (ngx_http_find_virtual_server(r, (u_char *) servername, len) != NGX_OK) {
|
||||||
ngx_strlen(servername))
|
|
||||||
!= NGX_OK)
|
|
||||||
{
|
|
||||||
return SSL_TLSEXT_ERR_NOACK;
|
return SSL_TLSEXT_ERR_NOACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1559,7 +1563,7 @@ ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len)
|
|||||||
ngx_http_core_srv_conf_t *cscf;
|
ngx_http_core_srv_conf_t *cscf;
|
||||||
u_char buf[32];
|
u_char buf[32];
|
||||||
|
|
||||||
if (len == 0 || r->virtual_names == NULL) {
|
if (r->virtual_names == NULL) {
|
||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user