I got some pretty strange behaviour here.
The latest dev exchanges the domain for the servers ip.

For a logged in user the css is linked like this
<link type="text/css" rel="stylesheet" href="//<domain.com>/sites/default/files/advagg_css/<longstring>.css" media="all" />

but for anonymous users the css is linked like this
<link type="text/css" rel="stylesheet" href="//<serverip>/sites/default/files/advagg_css/<longstring>.css" media="all" />

Why does it exchange the domain name for the ip?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nchase created an issue. See original summary.

Nchase’s picture

Issue summary: View changes
Nchase’s picture

the issue is more complicated. it also sometimes uses subdomains to link the css.
<link type="text/css" rel="stylesheet" href="//<subdomain.domain.com>/sites/default/files/advagg_css/<longstring>.css" media="all" />

Nchase’s picture

and the same happens to the js files

mikeytown2’s picture

https://api.drupal.org/api/drupal/includes%21file.inc/function/file_crea... Is what is being used in order to create the resource link.

Nchase’s picture

but that doesn't happen with any other module or drupals core css/js aggregation.

Nchase’s picture

Status: Active » Closed (works as designed)

ok, found the cause: wrong server configuration. closed

Niklan’s picture

@Nchase, how did you fix it. I have same issue on four different servers, with different OS's and web servers. Also, I have same problem on hosting.

This is only happens for CSS. All works fine, but for CSS all url replaced by IP's. FontAwesome is first what fails.

I temporary fix it by set $base_url variable in settings.php. But this is will not work for multidomain sites, but I have same issue on such sites. Why is that happens on both NGINX and Apache web servers?

mikeytown2’s picture

Status: Closed (works as designed) » Active

@Niklan
What value is $GLOBALS['base_url'] on your severs?
https://api.drupal.org/api/drupal/includes%21stream_wrappers.inc/functio...

And more importantly what is $_SERVER['HTTP_HOST'] & $_SERVER['SCRIPT_NAME'] on your servers?
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drup...

Nchase’s picture

the problem came with apache, which is able to listen at *:80. If your virtual host configuration is not set to a specific ip but to *:80 the advagg somehow resolves the hostname differently than drupal core does. Basically it finds every domain listed at the :80 port and brings it up.

mikeytown2’s picture

Category: Bug report » Support request
mikeytown2’s picture

Advagg uses core settings. It doesn't do it's own hostname lookup.

Nchase’s picture

can't be. the core doesn't throw that error. I had that error on 5 sites, and with core everything is fine. With advagg I wait for one cache clear cycle and then everything is a mess.

toschl’s picture

I had the same issue with css aggregation. I had:

url(/font.ttf)

And advagg converted this to:

url(//your-domain.com/sites/default/files/font.ttf)

Now as this is cached and another user visits www.your-domain.com (incl the www) he'll receives a

"Access to Font at 'https://your-domain.com/sites/default/files/font.ttf?5bdyw2' from origin 'https://www.your-domain.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource"

So best would be to keep the path relative instead of converting them to absolute ones.

mikeytown2’s picture

On admin/config/development/performance/advagg under Obscure Options check the "Do not run CSS url() values through file_create_url()" box. If you want to keep that setting unchecked you could also check "Convert absolute paths to be self references" as that should take care of this issue as well.

mikeytown2’s picture

Another thing to consider is to make https://your-domain.com redirect to https://www.your-domain.com

toschl’s picture

Thanks. This solved my problem.

NicholasS’s picture

I had probably the same issue as the original poster @Nchase, I determined, however, the site had multiple Domains registered for it, but only one had the proper SSL setup. So when bots/visitors brought up the site via the other http:// domains, it would generate CSS files with one of those other domains. But when you viewed the same page over the SSL/HTTPS domain you would get mixed content errors.

IMO - This feature of automatically appending the domain should be off by default.

mikeytown2’s picture

Status: Needs review » Needs work

The last submitted patch, 19: advagg-2833643-19-default-no-domain-css.patch, failed testing.

mikeytown2’s picture

mikeytown2’s picture

The last submitted patch, 21: advagg-2833643-21-default-no-domain-css.patch, failed testing.

The last submitted patch, 21: advagg-2833643-21-default-no-domain-css.patch, failed testing.

The last submitted patch, 21: advagg-2833643-21-default-no-domain-css.patch, failed testing.

  • mikeytown2 committed 0dfb753 on 7.x-2.x
    Issue #2833643 by mikeytown2: Change defaults; advagg exchanges domain...
mikeytown2’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

Rafal Lukawiecki’s picture

I am also experiencing this issue but perhaps for a different reason—see my support request #2923732: Host IP address shows up in links—incorrect HTTPRL config?.