console: support /pagespeed_console

sligocki is adding a feature to pagespeed where it will parse your statistics
for you and determine if there are any problems.  This CL wires up the
ConsoleHandler and also includes a few required files in the build process.

It doesn't work yet, because as of svn r3193 the console has a hardcoded json
request to '/mod_pagespeed_statistics' and in nginx we use '/ngx_...' .
I've tested this by changing all uses here to use the "mod_..." version and that
worked, but I've undone those changes.
This commit is contained in:
Jeff Kaufman
2013-06-24 16:58:40 -04:00
parent 0fc61adb30
commit 25e9fba38c
5 changed files with 33 additions and 2 deletions
+1
View File
@@ -87,6 +87,7 @@ location ~ "^/ngx_pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
location /pagespeed_console { allow 127.0.0.1; deny all; }
```
To confirm that the module is loaded, fetch a page and check that you see the
+2
View File
@@ -170,6 +170,8 @@ if [ $ngx_found = yes ]; then
$ps_src/ngx_thread_system.cc \
$ps_src/ngx_url_async_fetcher.cc \
$ps_src/pthread_shared_mem.cc \
$mod_pagespeed_dir/out/$buildtype/obj/gen/data2c_out/instaweb/net/instaweb/system/console_out.cc \
$mod_pagespeed_dir/out/$buildtype/obj/gen/data2c_out/instaweb/net/instaweb/system/console_css_out.cc \
$mod_pagespeed_dir/net/instaweb/system/add_headers_fetcher.cc \
$mod_pagespeed_dir/net/instaweb/system/loopback_route_fetcher.cc \
$mod_pagespeed_dir/net/instaweb/system/serf_url_async_fetcher.cc"
+2
View File
@@ -63,6 +63,8 @@ rsync -arvz "$MOD_PAGESPEED_SRC/" "psol/include/" --prune-empty-dirs \
--include="apr_memcache2.c" \
--include="loopback_route_fetcher.cc" \
--include="add_headers_fetcher.cc" \
--include="console_css_out.cc" \
--include="console_out.cc" \
--include="dense_hash_map" \
--include="dense_hash_set" \
--include="sparse_hash_map" \
+22
View File
@@ -48,6 +48,7 @@
#include "net/instaweb/rewriter/public/resource_fetch.h"
#include "net/instaweb/rewriter/public/rewrite_driver.h"
#include "net/instaweb/rewriter/public/static_asset_manager.h"
#include "net/instaweb/system/public/handlers.h"
#include "net/instaweb/public/global_constants.h"
#include "net/instaweb/public/version.h"
#include "net/instaweb/util/public/google_message_handler.h"
@@ -348,6 +349,7 @@ enum Response {
kPagespeedDisabled,
kBeacon,
kStatistics,
kConsole,
kMessages,
kPagespeedSubrequest,
kNotHeadOrGet,
@@ -1472,6 +1474,9 @@ CreateRequestContext::Response ps_create_request_context(
|| url.PathSansQuery() == "/ngx_pagespeed_global_statistics" ) {
return CreateRequestContext::kStatistics;
}
if (url.PathSansQuery() == "/pagespeed_console") {
return CreateRequestContext::kConsole;
}
if (url.PathSansQuery() == "/ngx_pagespeed_message") {
return CreateRequestContext::kMessages;
}
@@ -1925,6 +1930,7 @@ ngx_int_t ps_header_filter(ngx_http_request_t* r) {
case CreateRequestContext::kBeacon:
case CreateRequestContext::kStaticContent:
case CreateRequestContext::kStatistics:
case CreateRequestContext::kConsole:
case CreateRequestContext::kMessages:
case CreateRequestContext::kPagespeedSubrequest:
case CreateRequestContext::kPagespeedDisabled:
@@ -2151,6 +2157,20 @@ void ps_write_handler_response(const StringPiece& output, ngx_http_request_t* r,
ps_write_handler_response(output, r, net_instaweb::kContentTypeHtml, timer);
}
ngx_int_t ps_console_handler(
ngx_http_request_t* r,
net_instaweb::NgxServerContext* server_context) {
net_instaweb::NgxRewriteDriverFactory* factory =
static_cast<net_instaweb::NgxRewriteDriverFactory*>(
server_context->factory());
net_instaweb::MessageHandler* message_handler = factory->message_handler();
GoogleString output;
net_instaweb::StringWriter writer(&output);
ConsoleHandler(server_context, &writer, message_handler);
ps_write_handler_response(output, r, factory->timer());
return NGX_OK;
}
// TODO(oschaaf): port SPDY specific functionality, shmcache stats
// TODO(oschaaf): refactor this with the apache code to share this code
ngx_int_t ps_statistics_handler(
@@ -2508,6 +2528,8 @@ ngx_int_t ps_content_handler(ngx_http_request_t* r) {
return ps_static_handler(r);
case CreateRequestContext::kStatistics:
return ps_statistics_handler(r, cfg_s->server_context);
case CreateRequestContext::kConsole:
return ps_console_handler(r, cfg_s->server_context);
case CreateRequestContext::kMessages:
return ps_messages_handler(r, cfg_s->server_context);
case CreateRequestContext::kOk:
+4
View File
@@ -39,6 +39,10 @@ http {
# critical images to be inlined, so we just disable the option here.
pagespeed CriticalImagesBeaconEnabled false;
pagespeed Statistics on;
pagespeed StatisticsLogging on;
pagespeed LogDir "@@TEST_TMP@@/logdir";
server {
# Sets up a logical home-page server on
# max-cacheable-content-length.example.com. This server is only used to