I'm seeing 4 to 5 warnings on my status report page, like "The web servers configuration will need to be adjusted. The server should have responded with a 304, instead a 404 was returned.", as shown in the screenshot.

I use Drupal 7, Nginx, advagg 7.x-2.17 and httprl. Standard Nginx configuration from https://github.com/perusio/drupal-with-nginx with minor adjustments (e.g., customized public path).

Here is how I debugged the issue:

When running following Drush command to simulate/track HTTP calls,

drush php-eval 'module_load_include("install", "advagg", "advagg");advagg_requirements("runtime");'

, I found following records in my Nginx log:

[17:04:46] "GET /sites/a.com/files/advagg_css/css__1452301485.css HTTP/1.0" 404 4080
[17:04:46] "GET /sites/a.com/files/advagg_js/js__1452301485.js HTTP/1.0" 404 4080
[17:04:46] "GET /sites/a.com/files/advagg_css/css__1.css HTTP/1.0" 200 23291
[17:04:46] "GET /sites/a.com/files/advagg_css/sites/a.com/files/advagg_css/css__1.css HTTP/1.0" 404 162
[17:04:46] "GET /sites/a.com/files/advagg_css/css__1.css HTTP/1.1" 200 6982
[17:04:46] "GET /sites/a.com/files/advagg_css/sites/a.com/files/advagg_css/css__1.css HTTP/1.1" 404 136
[17:04:46] "GET /sites/a.com/files/advagg_js/js__2.js HTTP/1.0" 200 3400
[17:04:46] "GET /sites/a.com/files/advagg_js/sites/a.com/files/advagg_js/js__2.js HTTP/1.0" 404 162
[17:04:46] "GET /sites/a.com/files/advagg_js/sites/a.com/files/advagg_js/js__2.js HTTP/1.0" 404 162
[17:04:46] "GET /sites/a.com/files/advagg_js/js__2.js HTTP/1.1" 200 1188
[17:04:46] "GET /sites/a.com/files/advagg_js/sites/a.com/files/advagg_js/js__2.js HTTP/1.1" 404 136
[17:04:46] "GET /sites/a.com/files/advagg_js/sites/a.com/files/advagg_js/js__2.js HTTP/1.1" 404 136

(NOTE: I've cleaned up the logs making them shorter and clearer.)

If we just read the last 3 lines: First it made an HTTP request to an advagg JS file, with HTTP 200 returned; then made an HTTP request to an advagg JS file with incorrect URL being used (path public:// being used twice to generate the URL), causing an HTTP 404 returned.

My question is: how could the wrong URL "/sites/a.com/files/advagg_js/sites/a.com/files/advagg_js/js__2.js" being created? Has anyone seen anything like this before? I'm wondering if it's a configuration issue or a coding issue.

Thanks

Comments

deminy created an issue. See original summary.

mikeytown2’s picture

Looks like some requests are hitting the correct path "/sites/a.com/files/advagg_css/" while others seem to be doubled like "/sites/a.com/files/advagg_css/sites/a.com/files/advagg_css/"

Looking over the code and it appears that file_create_url() gets called twice while checking out 304s so that could be the cause. Will check this out more next week.

dimon00’s picture

Same configuration:
Drupal 7, Nginx, advagg 7.x-2.17 and httprl
same error.
I add I'm on https.

Regards

mikeytown2’s picture

Is the actual file being requested "js__2.js" or is it "js__$TIMESTAMP.js" or "js__-so9_-GCk165815N_ym54k4z1cK6jKpChLOuXC1kO58__SgMOIYjhipumaF_bGbiWLQL2vw_qjqI6ulM02gNeCo4__T5QKUgDU4661vEL1Rhnc4VoezWjF_OEIrNP-nIz0UI8.js"

This key bit of information will help me narrow down what part of the code I need to look at.

Also what does this output?
drush php-eval 'list($css_path, $js_path) = advagg_get_root_files_dir(); echo file_create_url($css_path[0]) . " " . file_create_url($js_path[0]);'

deminy’s picture

Only the first two requests are ""js__$TIMESTAMP.js" files; the rest are all "js__-so9_-GCk165815N_ym54k4z1cK6jKpChLOuXC1kO58__SgMOIYjhipumaF_bGbiWLQL2vw_qjqI6ulM02gNeCo4__T5QKUgDU4661vEL1Rhnc4VoezWjF_OEIrNP-nIz0UI8.js" style requests.

Command:

drush  php-eval 'list($css_path, $js_path) = advagg_get_root_files_dir(); echo $css_path[0] . " " . $js_path[0];'

Output: public://advagg_css public://advagg_js

Command: php-eval 'list($css_path, $js_path) = advagg_get_root_files_dir(); echo file_create_url($css_path[0]) . " " . file_create_url($js_path[0]);'

Output: http://a.com/sites/a.com/files/advagg_css http://a.com/sites/a.com/files/advagg_js

Thanks

mikeytown2’s picture

And what about when it's wrapped in file_create_url?

drush php-eval 'list($css_path, $js_path) = advagg_get_root_files_dir(); echo file_create_url($css_path[0]) . " " . file_create_url($js_path[0]);'

deminy’s picture

@mikeytown2, I updated my previous post with additional answers. Please check.

mikeytown2’s picture

Output of this?
drush php-eval 'echo variable_get("file_public_path", conf_path() . "/files") . " " . file_create_url("public://");'

deminy’s picture

Command: drush php-eval 'echo variable_get("file_public_path", conf_path() . "/files") . " " . file_create_url("public://") . "\n";'

Output: sites/a.com/files http://a.com/sites/a.com/files/

Command: drush vget file_public_path
Output: file_public_path: sites/a.com/files

  • mikeytown2 committed 2695fad on 7.x-2.x
    Issue #2647144 by mikeytown2: Fix issue with status report; double...
mikeytown2’s picture

Status: Active » Fixed
StatusFileSize
new1.47 KB

I think this will fix the reported issue. Please re-open if this is still not fixed.

deminy’s picture

StatusFileSize
new145.81 KB

Thanks for the patch; now another issue raised on status report page: "The web servers configuration will need to be adjusted. The server should have responded with a 304, instead a 200 was returned."

When running following Drush command to simulate/track HTTP calls,

drush php-eval 'module_load_include("install", "advagg", "advagg");advagg_requirements("runtime");'

, I found following records in my Nginx log:

[15:45:00] "GET /sites/a.com/files/advagg_css/css__1452642299.css HTTP/1.0" 404 40802
[15:45:00] "GET /sites/a.com/files/advagg_js/js__1452642299.js HTTP/1.0" 404 40802
[15:45:00] "GET /sites/a.com/files/advagg_css/css__1.css HTTP/1.0" 200 519002
[15:45:01] "GET /sites/a.com/files/advagg_css/css__1.css HTTP/1.0" 200 519002
[15:45:01] "GET /sites/a.com/files/advagg_css/css__1.css HTTP/1.0" 200 519002
[15:45:01] "GET /sites/a.com/files/advagg_css/css__1.css HTTP/1.1" 200 143652
[15:45:01] "GET /sites/a.com/files/advagg_css/css__1.css HTTP/1.1" 200 143652
[15:45:01] "GET /sites/a.com/files/advagg_css/css__1.css HTTP/1.1" 200 143652
[15:45:01] "GET /sites/a.com/files/advagg_js/js__2.js HTTP/1.0" 200 42552
[15:45:01] "GET /sites/a.com/files/advagg_js/js__2.js HTTP/1.0" 200 42552
[15:45:01] "GET /sites/a.com/files/advagg_js/js__2.js HTTP/1.0" 200 42552
[15:45:01] "GET /sites/a.com/files/advagg_js/js__2.js HTTP/1.1" 200 16112
[15:45:01] "GET /sites/a.com/files/advagg_js/js__2.js HTTP/1.1" 200 16112
[15:45:01] "GET /sites/a.com/files/advagg_js/js__2.js HTTP/1.1" 200 16112

Screenshot of Status Report page attached.

deminy’s picture

Status: Fixed » Active
deminy’s picture

It could be just a Nginx configuration issue. I might need to double check my Nginx configurations. Will post an update if I find something.

mikeytown2’s picture

Can you run this?

drush php-eval 'module_load_include("install", "advagg"); list($css_path) = advagg_get_root_files_dir(); $filename = advagg_install_get_first_advagg_file($file_path, "css"); $url = file_create_url($css_path[0] . "/" . $filename); $options = array("headers" => array("Accept-Encoding" => "gzip, deflate",),"version" =>"1.0"); advagg_install_url_mod($url, $options, FALSE); $request = drupal_http_request($url, $options); if (isset($request->headers["last-modified"])) { $if_modified_options = $options; $if_modified_options["headers"] = array("Accept-Encoding" => "gzip, deflate","If-Modified-Since" => $request->headers["last-modified"]); advagg_install_url_mod($url, $if_modified_options, FALSE); $request_304 = drupal_http_request($url, $if_modified_options); if ($request_304->code == 304) { echo $request_304->status_message;} else { print_r($request_304);} } else { echo "no last-modified"; }'

deminy’s picture

2nd execution outputs "no last-modified". I assume it should be an Nginx configuration issue. Will post an update next few days once I find something.

mikeytown2’s picture

deminy’s picture

Thanks mikeytown2. I've played with advagg-suggested configurations ( http://cgit.drupalcode.org/advagg/tree/README.txt#n480 ) and configurations from https://github.com/perusio/drupal-with-nginx; also tried to disable/enable httprl, use different advagg/httprl configurations, use localhost instead of server name (different IP) when making requests, etc. However, I still can't get HTTP 304 responses back (I don't use proxy servers).

I will try to dig more into it by myself first, and will let you know if I find anything or need any help from you.

mikeytown2’s picture

expires max; is what allows for the last-modified header to work.

mikeytown2’s picture

Is there a add_header Last-Modified ""; anywhere in your configuration? You can also try adding etag on and removing add_header ETag "";.

mikeytown2’s picture

Category: Bug report » Support request

Moving this to a support request as that seems to be the direction that this issue has taken.

Anonymous’s picture

@deminy: Removing the add_header Last-Modified 'Wed, 20 Jan 1988 04:20:42 GMT'; tag from perusio's config solves the HTTP 200 issue with AdvAgg.

--- a/apps/drupal/drupal.conf
+++ b/apps/drupal/drupal.conf
@@ -93,7 +93,6 @@ location / {
     location ^~ /sites/default/files/advagg_css/ {
         expires max;
         add_header ETag '';
-        add_header Last-Modified 'Wed, 20 Jan 1988 04:20:42 GMT';
         add_header Accept-Ranges '';

         location ~* /sites/default/files/advagg_css/css[_[:alnum:]]+\.css$ {
@@ -107,7 +106,6 @@ location / {
     location ^~ /sites/default/files/advagg_js/ {
         expires max;
         add_header ETag '';
-        add_header Last-Modified 'Wed, 20 Jan 1988 04:20:42 GMT';
         add_header Accept-Ranges '';

         location ~* /sites/default/files/advagg_js/js[_[:alnum:]]+\.js$ {
shane birley’s picture

I am not sure if this is related but around mid-December, I started seeing HTTP 0 statuses happening. I have been unable to update module status, unable to install new modules through the web UI, etc.

I am finally getting around to testing today and in every instance, if I remove AdvAgg, the problem goes away. No errors are being tossed, nothing in the server logs -- Drupal just says: HTTP 0. Boom.

I thought I would look here and make a report about what I have been seeing but this might be the same issue just in a different way?

mikeytown2’s picture

@Shane Birley
Try removing httprl instead of advagg.

Code that might be related inside advagg.install

    if (defined('VERSION') && floatval(VERSION) >= 7.22 && is_callable('httprl_override_core')) {
      $old = variable_get('drupal_http_request_function', FALSE);
      $GLOBALS['conf']['drupal_http_request_function'] = 'httprl_override_core';

      // Only test 1.1; 1.0 is rarely used these days.
      $requirements = $old_requirements;

      $options['version'] = '1.1';
      advagg_install_chk_urls($requirements, $urls, $options, $mod_url, $type, $url_path, $file_path, $filename);

      $GLOBALS['conf']['drupal_http_request_function'] = $old;
    }
shane birley’s picture

Ah ha. HTTPRL appears to be the culprit as I use it on almost everything. I will update and test it on the latest HTTPRL dev to confirm.

*UPDATE*

Confirmed. HTTPRL is the problem. Both latest dev and current release.

  • mikeytown2 committed e78e62c on 7.x-2.x
    Issue #2647144 by mikeytown2: Add in note about bad nginx config and fix...
mikeytown2’s picture

Status: Active » Fixed
StatusFileSize
new19.41 KB

Going to mark this issue as fixed. I've added a note in the nginx config section due to what was said in #22. Also fixed some markdown formatting issues.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.