docker / awesome-compose

Awesome Docker Compose samples
https://docs.docker.com/compose/
Creative Commons Zero v1.0 Universal
33.62k stars 6.47k forks source link

GTM Server-Side Tracking Setup is not working using local VirtualHost with docker #358

Open sajjadh47 opened 1 year ago

sajjadh47 commented 1 year ago

I am testing the GTM server side installation inside my Windows powered docker. I will explain all the steps I am doing and please do correct me what I am doing wrong.

1: I am creating two domain-subdomain in my WAMP Apache server using below code (which works fine)

<VirtualHost *:80>
    ServerName ssgtm.dev
    RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

<VirtualHost *:80>
    ServerName preview.ssgtm.dev
    RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

2: And these for proxying and SSL

<VirtualHost _default_:443>
    ServerName ssgtm.dev:443

    ProxyPreserveHost On
    ProxyRequests Off

    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

    SSLEngine on
    SSLCertificateFile "C:/ssls/ssgtm.dev.crt"
    SSLCertificateKeyFile "C:/ssls/ssgtm.dev.key"
</VirtualHost>

<VirtualHost _default_:443>
    ServerName preview.ssgtm.dev:443

    ProxyPreserveHost On
    ProxyRequests Off

    ProxyPass / http://localhost:8079/
    ProxyPassReverse / http://localhost:8079/

    SSLEngine on
    SSLCertificateFile "C:/ssls/preview.ssgtm.dev.crt"
    SSLCertificateKeyFile "C:/ssls/preview.ssgtm.dev.key"
</VirtualHost>

And now setting docker container:

https://gist.github.com/sajjadh47/234acc3e23223a7c30cef6acc202b9b4

At this point everthing works fine... I can visit both sites and check the /healthz printing ok...

https://i.stack.imgur.com/9rI8A.png

https://i.stack.imgur.com/ilfNO.png

I have added the domain in GTM settings too.. https://i.stack.imgur.com/Jp7EE.png

When now I go to check the tracking : https://ssgtm.dev/?test=ok amd https://ssgtm.dev/gtm/debug?id=GTM-000000&gtm_auth=000000&gtm_preview=env-3 It prints below error in the debug console :

An exception was thrown while proxying preview request. Make sure the PREVIEW_SERVER_URL is set correctly and the preview server is healthy. Message: connect ECONNREFUSED 127.0.0.1:443 What I am thinking is that the tagging server is not able to connect with the preview server? or it is because of the custom virtual domain in my apache local? Any help would be appreciated. Thanks

michaelCaleyWhaley commented 1 month ago

I am having a very similar problem. Did you ever manage to solve?