I have a production site, that's living behind a http auth password. Earlier today I notice *some* css files were not loading some pages were entirely or partially unstyled. For instance the home page was entirely unstyled, whilst on admin pages, the main page content was styled fine, however the sidebar menu provided by the admin module was unstyled.

Trying to load the CSS files gave a 404.

I was wondering whether this is because the site is at some point trying to access itself using the domain name provided (I have not entered a value in the "IP ADDRESS TO SEND ALL ASYNCHRONOUS REQUESTS TO:" field) but is not taking into account the http auth password? Or is that not how this module functions, and I should be looking elsewhere for the cure to my not-generating CSS files?

Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SocialNicheGuru’s picture

Title: How would ASYNC mode work when the site is behind a http auth password? » is there anyway to allow for http auth and the use of advagg?
Version: 6.x-1.9 » 7.x-2.7
Issue summary: View changes

it gives the following status on the status page:
Adv CSS/JS Agg - gzip Gzip is failing for css files.
The web servers configuration will need to be adjusted. In most cases make sure that the webroots .htaccess file still contains this section "Rules to correctly serve gzip compressed CSS and JS files". Certain default web server configurations (nginx) do not gzip HTTP/1.0 requests. Raw request info:

is there anyway to allow for http auth and the use of advagg?

  • mikeytown2 committed 29bbc2d on 7.x-2.x
    Issue #1668954 by mikeytown2: Pass along basic auth on the status report...
mikeytown2’s picture

Status: Active » Fixed
FileSize
820 bytes

Basic auth will get set for testing on the status report page now.

Status: Fixed » Closed (fixed)

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

Ollie222’s picture

I think I've come across this issue on a site I'm working on. It's behind a http auth and it looks like advagg is running correctly for css and js however the status page gives the following message.

Adv CSS/JS Agg - HTTP Request HTTP requests to advagg for css files are not getting through.
AdvAgg will issue a request for a file that does not exist inside of the AdvAgg directory. If AdvAgg sends a 404, everything is ok; if something else sends a 404 then that means that AdvAgg will not be able to generate an aggregate if it is missing as something else is handling the 404 before AdvAgg has a chance to do it. If you are reading this, it means that something else is handling the 404 before AdvAgg can. Raw request info:

stdClass Object
(
[request] => GET /sites/default/files/advagg_css/css__1427474545.css HTTP/1.0
Host: www.test.com
Connection: close
Referer: http://www.test.com/admin/reports/status
User-Agent: Drupal (+http://drupal.org/)

[data] =>

401 Authorization Required

Authorization Required

This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.

Additionally, a 401 Authorization Required
error was encountered while trying to use an ErrorDocument to handle the request.


Apache/2.2.29 (Unix) Server at www.test.com Port 80

[protocol] => HTTP/1.1
[status_message] => Authorization Required
[headers] => Array
(
[date] => Fri, 27 Mar 2015 16:42:25 GMT
[server] => Apache/2.2.29 (Unix)
[www-authenticate] => Basic realm="Demo"
[content-length] => 690
[connection] => close
[content-type] => text/html; charset=iso-8859-1
)

[code] => 401
[error] => Authorization Required
)

I'm running Drupal 7.35 and AdvAgg 7.x-2.7+147-dev which I think includes the patch you posted in #3.

mikeytown2’s picture

If everything is working correctly just add $conf['advagg_skip_404_check'] = TRUE; to your settings.php file and the error msg will go away.

Ollie222’s picture

Thanks for the quick reply.

I believe advagg is working, when activated it serves the specified number of aggregated css and jss files.

Adding your config setting does suppress the errors in the status report.

There is also a warning that appears in the status report reagrding gzip compression not working. The error again only appears if the site is password protected and I think the served files are being compressed (pagespeed doesn't moan about them not being) but any advice on how I can check this would be appreciated.

The warning that appears is

Warning
Adv CSS/JS Agg - gzip Gzip is failing for css files.
The web servers configuration will need to be adjusted. In most cases make sure that the webroots .htaccess file still contains this section "Rules to correctly serve gzip compressed CSS and JS files". Certain default web server configurations (nginx) do not gzip HTTP/1.0 requests. If you are using cloudfront you will have to add metadata to the .gz files. There are some other options if using cloudfront. Raw request info:

stdClass Object
(
[request] => GET /sites/default/files/advagg_css/css__AZX7BBJPh28r-dWjbmtB2S-cTKdchXMmvoHlM1FPSVY___6w-0v6JOKZBkz9CGnLxmAQNqwOYXCHkIQQQ7N_IQAY__ijUretfesLnvNhXNMszyVH1Ibf5Pmm5ULTXOV9rSBdw.css HTTP/1.0
Accept-Encoding: gzip, deflate
Host: www.test.com
Connection: close
Referer: http://www.test.com/admin/reports/status
User-Agent: Drupal (+http://drupal.org/)

[data] => ...
[protocol] => HTTP/1.1
[status_message] => Authorization Required
[headers] => Array
(
[date] => Mon, 30 Mar 2015 11:38:49 GMT
[server] => Apache/2.2.29 (Unix)
[www-authenticate] => Basic realm="Demo"
[content-length] => 690
[connection] => close
[content-type] => text/html; charset=iso-8859-1
)

[code] => 401
[error] => Authorization Required
)

SocialNicheGuru’s picture

is there a way to pass the http auth user/password to advagg?

Ollie222’s picture

I think if you have the latest dev version or the patch in #3 then the code in that patch allows for that by setting the variables shield_user and shield_pass or if those are not set then it uses $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] .

While the status page looks to have a few issues the main code looks to work, in my case at least.

mikeytown2’s picture

Status: Closed (fixed) » Active

Looks like I need to provide better feedback on a 401 on the status report page; with the option of a settings.php override.

Ollie222’s picture

It would be useful if possible.

We often use password protection for beta sites to stop people and search engines seeing them before they're ready and I imagine we're not alone.

Thanks for the quick support and the great module.

mikeytown2’s picture

Status: Active » Needs review
FileSize
2.22 KB

Can you test this and see if by following the directions things work?

Status: Needs review » Needs work

The last submitted patch, 12: advagg-1668954-12-basic-auth.patch, failed testing.

Ollie222’s picture

For some reason your patch in #12 fails to apply to the dev version of Advagg that I have here but I've applied it manually.

I believe prior to PHP 5.5 (I'm testing this on 5.3) the function empty can't have a function as a value, only a variable. Using a function it returns the error 'Can't use function return value in write context'.

Changing

elseif(!empty(variable_get('shield_user', ADVAGG_AUTH_BASIC_USER))){

to

elseif (variable_get('advagg_auth_basic_user', ADVAGG_AUTH_BASIC_USER) != '') {

stops this error.

After this the normal error messages still appear in status report.

Changing

elseif ($request->code != 401) {

to

elseif ($request->code == 401) {

makes the new message appear in the status report.

If I set $conf['advagg_auth_basic_user'] and $conf['advagg_auth_basic_pass'] correctly nothing changes and the new message to set the user and password still appear in the status report.

I've not looked at the next bit of code in great detail but if I understand it correctly then the status report calls a css and js url such as

/sites/default/files/advagg_css/css__1427795896.css
/sites/default/files/advagg_js/js__1427795896.js

in the function advagg_install_url_mod.

The part that sets the username and password looks to be bypassed completely because $mod_url is false when this function is called.

As mentioned I've not looked any further yet but if you want me to test anything else then please let me know.

mikeytown2’s picture

Status: Needs work » Needs review
FileSize
3.77 KB

Thanks for the feedback! New patch for you to test.

Status: Needs review » Needs work

The last submitted patch, 15: advagg-1668954-14-basic-auth.patch, failed testing.

mikeytown2’s picture

Version: 7.x-2.7 » 7.x-2.x-dev

Status: Needs work » Needs review

The last submitted patch, 3: advagg-1668954-2-pass-basic-auth-in-status-report-test.patch, failed testing.

Ollie222’s picture

I've just pulled down a fresh copy of the latest dev version and the patch in #15 applied to it cleanly.

Both of the css and js error and also the css compression warning on the status report page have now gone and when I look at the files being served when visiting a webpage they are aggregated.

It works for me without me having to set the username and password in the settings file, presumably it's now using the values supplied by the browser.

So all in all it's looking good to me.

The only issue I have now is that I'm using an Omega 3 based theme and sometimes the desktop css is not rendering correctly on all pages (works fine 90% of the time) but I don't believe this is related to this issue and I'll raise it as a separate post if I can't fix it.

Thanks for your quick updates on this issue they're much appreciated.

mikeytown2’s picture

Status: Needs review » Fixed

Patch has been committed.

  • mikeytown2 committed f48d56d on 7.x-2.x
    Issue #1668954 by mikeytown2: is there anyway to allow for http auth and...

Status: Fixed » Closed (fixed)

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

SocialNicheGuru’s picture

Where is the fieldset to add the http user/password or is it just a config variable?

mikeytown2’s picture

Just a conf variable. You can also manually call variable_set.