Rewriting A Single Resource URL On A Webpage
-
A client is using a marketing automation tool called Mautic. His website has the proper SSL certs via a Nginx proxy and Let's Encrypt. The marketing automation tool creates a landing page for his to have a double opt-in email. Problem is that, when presenting the landing page after someone clicks on the link to confirm their email address, there is one single resource that remains HTTP vs HTTPS. It's available via HTTPS (I've tested it) but for some reason, this tool is only adding the HTTP link for the javascript during webpage presentation.
Is there a way to use Nginx to force a rewrite of this single resource link? It is the only one that refuses to play. Here is what it looks like...
Currently (which breaks proper tracking because the script is blocked by most browsers):
<script src="http://sub.domain.com/mtc.js" async data-source="mautic"></script>
What I want:
<script src="https://sub.domain.com/mtc.js" async data-source="mautic"></script>
Is there a way I can rewrite that single resource URL? The Nginx config file already includes this
return 301 https://$server_name$request_uri;
line which I thought would take care of it but there must be something happening during page render that is preventing the rewrite (unless I'm misunderstanding how this works).If that can't happen, will setting up his DNS via Cloudflare handle this?
-
@nashbrydges said in Rewriting A Single Resource URL On A Webpage:
If that can't happen, will setting up his DNS via Cloudflare handle this?
Yes, because cloudflare terminates the SSL.
-
@nashbrydges said in Rewriting A Single Resource URL On A Webpage:
Currently (which breaks proper tracking because the script is blocked by most browsers):
<script src="http://sub.domain.com/mtc.js" async data-source="mautic"></script>A location should handle this.
in your :80 server block add a location
location /mtc.jc { rewrtie ^ https://sub.domain.com/mtc.js; }
-
@jaredbusch said in Rewriting A Single Resource URL On A Webpage:
@nashbrydges said in Rewriting A Single Resource URL On A Webpage:
Currently (which breaks proper tracking because the script is blocked by most browsers):
<script src="http://sub.domain.com/mtc.js" async data-source="mautic"></script>A location should handle this.
in your :80 server block add a location
location /mtc.jc { rewrtie ^ https://sub.domain.com/mtc.js; }
Thanks, I'll give that a try.
-
@nashbrydges said in Rewriting A Single Resource URL On A Webpage:
@jaredbusch said in Rewriting A Single Resource URL On A Webpage:
@nashbrydges said in Rewriting A Single Resource URL On A Webpage:
Currently (which breaks proper tracking because the script is blocked by most browsers):
<script src="http://sub.domain.com/mtc.js" async data-source="mautic"></script>A location should handle this.
in your :80 server block add a location
location /mtc.jc { rewrtie ^ https://sub.domain.com/mtc.js; }
Thanks, I'll give that a try.
Pulled that right out of my ass, it very well may not work. But you get the general idea.
-
@jaredbusch said in Rewriting A Single Resource URL On A Webpage:
@nashbrydges said in Rewriting A Single Resource URL On A Webpage:
@jaredbusch said in Rewriting A Single Resource URL On A Webpage:
@nashbrydges said in Rewriting A Single Resource URL On A Webpage:
Currently (which breaks proper tracking because the script is blocked by most browsers):
<script src="http://sub.domain.com/mtc.js" async data-source="mautic"></script>A location should handle this.
in your :80 server block add a location
location /mtc.jc { rewrtie ^ https://sub.domain.com/mtc.js; }
Thanks, I'll give that a try.
Pulled that right out of my ass, it very well may not work. But you get the general idea.
It does work, as I have used it on Apache like my post below:
https://mangolassi.it/topic/16660/reverse-or-forward-proxy-setup/3