Support » Plugin: LiteSpeed Cache » CDN rewrites & hotlink protection issue

  • Resolved miketemby

    (@miketemby)


    I am using BunnyCDN and have hotlink protection enabled so direct file access is only allowed from my website.

    Within the LS CDN settings only the following attributes should be replaced:

    
    .src
    .data-src
    .href
    .poster
    source.srcset
    

    However og image meta tags are being rewritten as well despite the attribute being content and not in the list of replacement attributes
    <meta property="og:image" content="https://cdn....fb-og-image.jpg">
    <meta name="twitter:image" content="https://cdn....fb-og-image.jpg">

    This is causing all shared images to not appear because obviously the hotlink protection prevents it…

    I do not see any option to put exclude rules for specific tags. How can this be resolved?

    • This topic was modified 8 months, 2 weeks ago by miketemby.
    • This topic was modified 8 months, 2 weeks ago by miketemby.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    I added

    
    <meta property="og:image" content="https://xxxv/wp-content/uploads/2021/11/some.jpg">
    	</head>
    

    to my header section and it didn’t get rewritten

    please provide some more detail information how to reproduce the issue

    Best regards,

    Thread Starter miketemby

    (@miketemby)

    ok, well these particular meta tags are added by RankMath. The image sources are local in RM but once I turn on CDN mapping in LS Cache, they get rewritten to use the CDN.

    CDN Mapping Example

    I also tried manually adding a meta tag and it did not get re-written which makes me think that either LS Cache has some edge cases included for Rank Math, or the manner in which RM is adding them causes LS Cache to re-write them anyway.

    • This reply was modified 8 months, 2 weeks ago by miketemby.
    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    okay …

    since I am not familiar with rankmath , could you please give me some instructions for how to make it add these <meta tag into my page ?

    Best regards,

    Thread Starter miketemby

    (@miketemby)

    All you need to do is install RM and add a FB default image either during the setup stage, or afterward in RankMath > Titles&Meta > Global Meta under OpenGraph Thumbnail – this will be used as the default for all pages.

    I have done some digging into the RM code and I can see that the image URL is being altered by LS Cache well before the meta tags are actually constructed and output on the page.
    I debugged the core variable holding the image meta data in the middle of the process, well before it is compiled into the html meta tag, and it already had the cdn prefix…

    Array ( 
        [id] => 1623 
        [url] => https://cdn.dev.haemochromatosis.org.au/wp-content/uploads/2021/11/fb-og-image.jpg 
        [width] => 1200 
        [height] => 630 
        [type] => image/jpeg 
        [alt] => Haemochromatosis )
    
    Thread Starter miketemby

    (@miketemby)

    ..and here is the log if LS Cache doing the re-write. For some reason it tries to immediately rewrite the rewritten path too.. odd.

    11/30/21 11:41:45.084 [ 1 2UE] [CDN] rewrite http://dev.haemochromatosis.org.au/wp-content/uploads/2021/11/fb-og-image.jpg
    11/30/21 11:41:45.084 [ 1 2UE] [CDN] -rewritten: https://cdn.dev.haemochromatosis.org.au/wp-content/uploads/2021/11/fb-og-image.jpg
    11/30/21 11:41:45.085 [ 1 2UE] [CDN] rewrite https://cdn.dev.haemochromatosis.org.au/wp-content/uploads/2021/11/fb-og-image.jpg
    11/30/21 11:41:45.085 [ 1 2UE] [CDN] -rewrite failed: host not internal
    • This reply was modified 8 months, 2 weeks ago by miketemby.
    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    I’ve managed to reproduce it , will notify our developers for further investigation

    Best regards,

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    okay , it seems the RM grabs the image URL at end of page generation , which the images were already rewritten

    I am not sure if there is anything we can do from our side , I would suggest you ask RM to make it forcefully stick on wp home domain instead of grabbing image URL with CDN domain.

    Best regards,

    Thread Starter miketemby

    (@miketemby)

    Can you please clarify what you mean here?

    The image in question does not exist anywhere else on the page. It is gathered by image id from RM settings and the meta tag is built from that – it is not gathered from elsewhere on the page so how can LS Cache be re-writing it?

    Are you saying that LS Cache is re-writing all internal image urls even where they don’t exist on he page, so any function handling an image url will automatically get the re-written url even if it has nothing to do with the page?

    This explanation actually makes no sense, because LS Cache is supposed to be re-writing urls based on HTML attributes…. it has no HTML attribute before it is inserted onto the page within the meta tag on which it’s HTML attribute is content.

    • This reply was modified 8 months, 1 week ago by miketemby.
    • This reply was modified 8 months, 1 week ago by miketemby.
    • This reply was modified 8 months, 1 week ago by miketemby.
    • This reply was modified 8 months, 1 week ago by miketemby.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘CDN rewrites & hotlink protection issue’ is closed to new replies.