Problem/Motivation

The "tracker.min.js" is blocked by Chrome. I noticed this in the Chrome dev tools console. The message: "blocked:mixed-content".

The site is being served via "https://example.com" but the console reports it trying to load from "http://example.com/modules/contrib/visitors/js/tracker.min.js" (http instead of https) which is why Google is blocking the script from being loaded.

My setup is probably more convoluted than others. I have a Nginx reverse proxy (which provides the https via letsencrypt) which then passes the traffic to a "drupal:11" Docker container running the site (which is apache).

Steps to reproduce

I was able to reproduce the issue on my dev machine, although the issue is not https vs http, but rather that the port being served is 8080 externally and 80 internally. The following instructions should allow you to reproduce in your own environment, provided you have docker and docker-compose installed. I'm assuming that a shell is being used.

  1. Create a directory "test_visitors"
  2. In "test_visitors" create the file "docker-compose.yml" and copy the text for the compose file (see below)
  3. Still in the "test_visitors" run the command: docker compose up
  4. Open a browser and point it to "http://localhost:8080". Setup a drupal site. Note, the database settings are, database=drupal, user=postgres, password=example, Advanced \ host=postgres, Advanced \ port=5432. The other settings shouldn't matter too much (i think), but at the end you should be logged in as the site admin.
  5. In another terminal window, run the command (to get to the container shell): docker exec -it drupal_test /bin/bash
  6. In the container shell, run the following commands:
    • apt update
    • apt install git -y
    • composer require 'drupal/visitors:^2.x-dev'
    • composer require 'drush/drush'
    • drush cr
    • exit
  7. In the Drupal admin, install visitors and then configure it.
  8. Load the drupal site in a browser that is not authenticated (http://localhost:8080). Open the Chrome debug console to the Network tab and notice that "tracker.min.js" does not load. Note: if you open the debug after loading the page, you will need to reload the page to see the Network populate with information.

docker-compose.yml

version: '3.1'
services:
  drupal:
    image: drupal:11
    container_name: drupal_test
    ports:
      - 8080:80
    volumes:
      - /var/www/html/modules
      - /var/www/html/profiles
      - /var/www/html/themes
      - /var/www/html/sites
    restart: always
  postgres:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: example
    restart: always

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork visitors-3494874

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bluegeek9’s picture

Assigned: Unassigned » bluegeek9

  • bluegeek9 committed d59254cb on 3.0.x
    Issue #3494874: Reverse proxy: tracker.min.js blocked from loading (...

  • bluegeek9 committed aab82f50 on 8.x-2.x
    Issue #3494874: Reverse proxy: tracker.min.js blocked from loading (...
bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Fixed

Thank you Wes!

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support to this project makes other volunteer contributions more sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triaging issues and adding more context to existing issues.
  • Writing documentation or patches for this project.
wes.congruityworks.com’s picture

Thanks Steve, your quick responses have been great.

Status: Fixed » Closed (fixed)

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

bluegeek9’s picture

Updating credits.