incubator-pagespeed-mod icon indicating copy to clipboard operation
incubator-pagespeed-mod copied to clipboard

Apache2: /mod_pagespeed_beacon returns 404

Open Argelbargel opened this issue 9 years ago • 5 comments

Hi there,

i've recently changed my setup from nginx to apache2 and can't get the Pagespeed-Beacon to work there. The request to the beacon always returns a 404 Status-Code. I'm using ProxyHTMLMeta to replace meta tags with the http-equiv-attribute that pagespeed ignores, but the problem does not seem related to that as the problem persits even if i disable ProxyHTMLMeta... Using the default-path (/mod_pagespeed_beacon) does not work also.

Is this a bug or am i doing something wrong?

Kind regards

Argelbargel

OS: Debian Jessie 8.21 Apache-Version: 2.4.20 Mod-Pagespeed-Version: 1.9.32.14-0 Apache-Configuration:

LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule filter_module modules/mod_filter.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule xml2enc_module modules/mod_xml2enc.so
LoadModule proxy_html_module modules/mod_proxy_html.so
# this is the file mod_pagespeed_ap24.so renamed to mod_pagespeed.so
LoadModule pagespeed_module modules/mod_pagespeed.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so

[...]

# see http://blog.cloudfour.com/should-i-remove-etags-from-my-headers/
Header unset ETag
FileETag None

ProxyPreserveHost On
ProxyRequests Off
ProxyMaxForwards 50
ProxyErrorOverride Off

ProxyHTMLEnable On
ProxyHTMLMeta On
# ProxyHTMLLinks is required so ProxyHTMLMeta replaces meta http-equiv
# as we do not want our html otherwise rewritten, use some non-existing tag & attribute
ProxyHTMLLinks none none

ModPagespeed on
ModPagespeedModifyCachingHeaders off
# hide pagespeed-version
ModPagespeedXHeaderValue mps

ModPagespeedFileCachePath /path/to/mod_pagespeed_cache/
ModPagespeedFileCacheSizeKb 102400
ModPagespeedFileCacheCleanIntervalMs 3600000
ModPagespeedFileCacheInodeLimit 500000
ModPagespeedLRUCacheKbPerProcess 1024
ModPagespeedLRUCacheByteLimit 16384
ModPagespeedCreateSharedMemoryMetadataCache "/var/cache/mod_pagespeed/" 51200
ModPagespeedRewriteDeadlinePerFlushMs 10
ModPagespeedImageMaxRewritesAtOnce      8

ModPagespeedStatistics on
ModPagespeedStatisticsLogging off
ModPagespeedStatisticsLoggingIntervalMs 60000
ModPagespeedStatisticsLoggingMaxFileSizeKb 1024
ModPagespeedMessageBufferSize 1000
ModPagespeedLogDir /path/to/pagespeed_logs

ModPagespeedRewriteLevel CoreFilters
ModPagespeedPreserveUrlRelativity on
ModPagespeedJsPreserveURLs On
ModPagespeedImagePreserveURLs On
ModPagespeedCssPreserveURLs On
ModPagespeedInPlaceResourceOptimization on
ModPagespeedEnableFilters remove_comments,collapse_whitespace,add_instrumentation
ModPagespeedDisableFilters inline_images,lazyload_images,convert_jpeg_to_webp,convert_to_webp_lossless,defer_javascript
ModPagespeedLoadFromFileMatch "^https?://*/static/" "/path/to/static/asset/files"
ModPagespeedReportUnloadTime on
ModPagespeedBeaconUrl "/pagespeed/beacon"

AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript     application/ecmascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE image/x-icon

<Location "/static">
    ProxyPass http://static-origin-host:port/
    ProxyPassReverse http://static-origin-host:port/
</Location>

<Location "/">
    ProxyPass http://dynamic-origin-host:port/
    ProxyPassReverse http://dynamic-origin-host:port/
</Location>

<LocationMatch "^/pagespeed/stat.*">
    ProxyPass !
    Require ip 127.0.0.1
    SetHandler mod_pagespeed_statistics
</LocationMatch>

<Location "/pagespeed/admin">
    ProxyPass !
    Require ip 127.0.0.1
    SetHandler pagespeed_admin
</Location>

<Location "/pagespeed/beacon">
    ProxyPass !
    Require all granted
    SetHandler mod_pagespeed_beacon
</Location>

<Location "/server-status">
    ProxyPass !
    SetHandler server-status
    Require ip 127.0.0.1
</Location>

[..]

Argelbargel avatar Apr 15 '16 11:04 Argelbargel

what does your error or access logs say about the mod_pagespeed_statistics urls that are being requested and 404d?

crowell avatar Apr 15 '16 14:04 crowell

error.log:

[Mon Apr 18 17:16:51.267815 2016] [core:trace5] [pid 12339:tid 139966633912064] protocol.c(616): [client 10.6.141.19:61730] Request received from client: GET /pagespeed/beacon?ets=load:1146&rload=1995&nav=3&dns=0&connect=0&req_start=80&ttfb=42&dwld=12&dom_c=1546&nt=0&ifr=0&url=http%3A%2F%2Fpath%2Fto%2Fserver-root%2Frun%2Fapache2-proxy.pid%3A8080%2Ftest%2Fcontent%2F HTTP/1.1
...
[Mon Apr 18 17:16:51.268409 2016] [core:info] [pid 12339:tid 139966633912064] [client 10.6.141.19:61730] AH00128: File does not exist: /path/to/document/root/pagespeed/beacon, referer: http://server:port/test/content/

It seems that the path is not handled by mod_pagespeed at all. access.log:

10.6.101.77 - - [18/Apr/2016:09:29:23 +0200] "GET /pagespeed/beacon?ets=load:398&rload=669&nav=0&dns=1&connect=4&req_start=6&ttfb=249&dwld=19&dom_c=549&nt=0&fp=662&ifr=0&ref=http%3A%2F%2Fserver%3A8080%2Fpath&url=http%3A%2F%2Fpath%2Fto%2Fserver-root%2Frun%2Fserver-name.pid%3A8080%2Ftest%2Fcontent%2Findex.html HTTP/1.1" 404 214 "http://server:port/test/content/index.html" "<User-Agent removed>"

Argelbargel avatar Apr 18 '16 15:04 Argelbargel

Hi, I have the same problem. The default beacon URL works but is blocked by several ad-blockers (in my case uBlock Origin). I used the following in latest httpd with mod_pagespeed, both built from source:

ModPagespeedBeaconUrl /pagespeed-callback

Apache error and access logs agree that there is a 404 on that URL; however, the pagespeed-admin and pagespeed-global-admin pages work fine. Admin pages are included like this:

<IfModule pagespeed_module>
    <Location /pagespeed-admin>
        <RequireAny>
                # a few Requires
        </RequireAny>
        RewriteEngine Off
        SetHandler pagespeed_admin
    </Location>

    <Location /pagespeed-global-admin>
        <RequireAny>
                # a few Requires
        </RequireAny>
        RewriteEngine Off
        SetHandler pagespeed_global_admin
    </Location>
</IfModule>

Beacon page is included like this:

<IfModule pagespeed_module>
    <Location /pagespeed-callback>
        RewriteEngine Off
        SetHandler mod_pagespeed_beacon
    </Location>
</IfModule>

GuillaumeRossolini avatar May 06 '16 11:05 GuillaumeRossolini

I've been looking into the code that wires up the beacons pretty closely (see https://github.com/pagespeed/mod_pagespeed/pull/1375) and tested a couple of things in light of this issue. On the bleeding edge I am not able to reproduce this - except when ModPagespeedInheritVHostConfig is off. A bit of a shot in the dark, but is that the case here?

oschaaf avatar Aug 12 '16 20:08 oschaaf

@GuillaumeRossolini

In your posted configuration, the line: "RewriteEngine Off" is a misconfiguration (all three of "RewriteEngine Off" are misconfiguration), and adding it to your system will not change any system behavior. Why "RewriteEngine Off" is allowed by Apache is that, if you include multiple "RewriteRule" parameters in your configuration, then instead of commenting them all, you can explicitly using “RewriteEngine Off” to disable all "RewriteRule".

More importantly, the default value of “RewriteEngine" is already an "off", so adding “RewriteEngine Off" is quite unnecessary and it may cause confusion to users.

Since herein there is no "RewriteRule", deleting “RewriteEngine Off” would be ideal.

Related Apache source code snippet:

run_rewritemap_programs(server_rec *s , apr_pool_t *p){
if (conf->state == ENGINE_DISABLED) { // usage of "RewriteEngine"
  return APR_SUCCESS; // early return
rewritemap_program(...); // usage of "RewriteRule" 
}

JialuZhang avatar Feb 24 '21 15:02 JialuZhang