最終更新: library_task 2010年11月27日(土) 10:22:16履歴
HTTPヘッダの受信を完了し、いよいよHTTPの処理を行っていくはずです。
r->plain_http = 1はngx_http_ssl_handshake()で入る可能性があります。
設定上でSSLを使っているのに、アクセスがSSLでなかった場合にr->plain_http = 1が入ります。
ngx_http_ssl_handshake()ではフラグセットのみで、ここでエラー応答としていますね。
SSLの部分は読み飛ばし〜。
とすると、処理は「ngx_http_handler()」と「ngx_http_run_posted_requests()」と続いていきますね。
次はngx_http_handler()を見ます。
1541 static void 1542 ngx_http_process_request(ngx_http_request_t *r) 1543 { 1544 ngx_connection_t *c; 1545 1546 c = r->connection; 1547 1548 if (r->plain_http) { 1549 ngx_log_error(NGX_LOG_INFO, c->log, 0, 1550 "client sent plain HTTP request to HTTPS port"); 1551 ngx_http_finalize_request(r, NGX_HTTP_TO_HTTPS); 1552 return; 1553 } 1554 1555 #if (NGX_HTTP_SSL) 1556 1557 if (c->ssl) { 1558 long rc; 1559 X509 *cert; 1560 ngx_http_ssl_srv_conf_t *sscf; 1561 1562 sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module); 1563 1564 if (sscf->verify) { 1565 rc = SSL_get_verify_result(c->ssl->connection); 1566 1567 if (rc != X509_V_OK) { 1568 ngx_log_error(NGX_LOG_INFO, c->log, 0, 1569 "client SSL certificate verify error: (%l:%s)", 1570 rc, X509_verify_cert_error_string(rc)); 1571 1572 ngx_ssl_remove_cached_session(sscf->ssl.ctx, 1573 (SSL_get0_session(c->ssl->connection))); 1574 1575 ngx_http_finalize_request(r, NGX_HTTPS_CERT_ERROR); 1576 return; 1577 } 1578 1579 if (sscf->verify == 1) { 1580 cert = SSL_get_peer_certificate(c->ssl->connection); 1581 1582 if (cert == NULL) { 1583 ngx_log_error(NGX_LOG_INFO, c->log, 0, 1584 "client sent no required SSL certificate"); 1585 1586 ngx_ssl_remove_cached_session(sscf->ssl.ctx, 1587 (SSL_get0_session(c->ssl->connection))); 1588 1589 ngx_http_finalize_request(r, NGX_HTTPS_NO_CERT); 1590 return; 1591 } 1592 1593 X509_free(cert); 1594 } 1595 } 1596 } 1597 1598 #endif 1599 1600 if (c->read->timer_set) { 1601 ngx_del_timer(c->read); 1602 } 1603 1604 #if (NGX_STAT_STUB) 1605 (void) ngx_atomic_fetch_add(ngx_stat_reading, -1); 1606 r->stat_reading = 0; 1607 (void) ngx_atomic_fetch_add(ngx_stat_writing, 1); 1608 r->stat_writing = 1; 1609 #endif 1610 1611 c->read->handler = ngx_http_request_handler; 1612 c->write->handler = ngx_http_request_handler; 1613 r->read_event_handler = ngx_http_block_reading; 1614 1615 ngx_http_handler(r); 1616 1617 ngx_http_run_posted_requests(c); 1618 }
r->plain_http = 1はngx_http_ssl_handshake()で入る可能性があります。
設定上でSSLを使っているのに、アクセスがSSLでなかった場合にr->plain_http = 1が入ります。
ngx_http_ssl_handshake()ではフラグセットのみで、ここでエラー応答としていますね。
SSLの部分は読み飛ばし〜。
とすると、処理は「ngx_http_handler()」と「ngx_http_run_posted_requests()」と続いていきますね。
次はngx_http_handler()を見ます。
コメントをかく