ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Rewriting A Single Resource URL On A Webpage

    Scheduled Pinned Locked Moved IT Discussion
    nginx
    6 Posts 3 Posters 742 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • NashBrydgesN
      NashBrydges
      last edited by

      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?

      JaredBuschJ 2 Replies Last reply Reply Quote 3
      • JaredBuschJ
        JaredBusch @NashBrydges
        last edited by

        @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.

        1 Reply Last reply Reply Quote 1
        • JaredBuschJ
          JaredBusch @NashBrydges
          last edited by JaredBusch

          @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;
          }
          
          NashBrydgesN 1 Reply Last reply Reply Quote 2
          • NashBrydgesN
            NashBrydges @JaredBusch
            last edited by

            @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.

            JaredBuschJ 1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch @NashBrydges
              last edited by

              @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.

              dbeatoD 1 Reply Last reply Reply Quote 1
              • dbeatoD
                dbeato @JaredBusch
                last edited by

                @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

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post