服务器端 GTM 不(总是)使用 Nginx/Docker 提供 gtag.js

问题描述 投票:0回答:1

我一直在使用 Docker 和 Google 的

gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable
镜像在服务器上手动设置服务器端 GTM。我将其与
Nginx
一起提供给虚拟主机,例如
sst.domain.com
。查看
healthz
将返回
200
好的消息。我一直在通过标签管理器配置服务器容器,并且全部按照文档进行设置。如果我使用容器配置
cURL
我的预览服务器,我可以关注 GTM 预览界面上的
page-view
事件。所以,一切看起来都很棒,直到我尝试从我的服务器加载
gtag.js
脚本。

使用chrome访问

https://sst.domain.com/gtag/js?id=G-XXXXXX
将导致
ERR_CONNECTION_REFUSED
,使用
cURL
将响应实际的js代码。如果我在应用程序中加载脚本如文档中所述,我会收到错误。请注意,我遵循了文档并在 GTM 中配置了客户端,以便我的服务器容器能够提供文件(特定 ID 的默认 gtag.js 路径)。

这让我认为我的网络服务器配置错误。关于我应该在我的conf文件中查看什么内容的任何线索?我已经尝试过

http1.1
,没有任何标题或其他
ssl
配置,这并没有改变我的问题。或者问题可能出在其他地方?谢谢!

server {
  listen 80;
  server_name sst.domain.com;

  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Frame-Options "SAMEORIGIN";
  add_header X-Content-Type-Options nosniff;
  add_header Set-Cookie "Path=/; HttpOnly; Secure";

}

server {
  listen 443 ssl;
  http2 on;
  server_name sst.domain.com;

  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Frame-Options "SAMEORIGIN";
  add_header X-Content-Type-Options nosniff;
  add_header Set-Cookie "Path=/; HttpOnly; Secure";

  ssl_session_timeout 1d;
  ssl_session_cache shared:MozSSL:10m;
  ssl_session_tickets off;

  ssl_protocols TLSv1.3;
  ssl_prefer_server_ciphers off;

  ssl_stapling on;
  ssl_stapling_verify on;

  ssl_certificate /etc/nginx/ssl/sst.domain.com.crt;
  ssl_certificate_key /etc/nginx/ssl/sst.domain.com.key;

  client_body_buffer_size 10K; 
  client_header_buffer_size 1k;
  client_max_body_size 8m;
  large_client_header_buffers 2 1k;

  client_body_timeout 40;
  client_header_timeout 40;
  keepalive_timeout 40;
  send_timeout 40;

  access_log off;

  location /preview/ {
    proxy_pass http://gtm-preview-server:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 40s;
    proxy_connect_timeout 40s;
    proxy_send_timeout 40s;
  }

  location / {
    proxy_pass http://gtm-tagging-cluster:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 40s;
    proxy_connect_timeout 40s;
    proxy_send_timeout 40s;
  }
}
nginx ssl docker-compose google-tag-manager
1个回答
0
投票

好吧,这只是网址中的拼写错误。 🙃

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.