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

Open
opened 2025-11-06 14:18:23 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @sajjadh47 on GitHub (May 26, 2023).

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

Originally created by @sajjadh47 on GitHub (May 26, 2023). 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
Author
Owner

@michaelCaleyWhaley commented on GitHub (Aug 7, 2024):

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

@michaelCaleyWhaley commented on GitHub (Aug 7, 2024): I am having a very similar problem. Did you ever manage to solve?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/awesome-compose#89