2017-09-28 3 views
3

最近、私はyandexの解析ツールを使用して、あなたの訪問者に関する詳細な情報を提供しています。 。ツールのリンクがある:それは完全に無料yandexのnginxの「X-Frame-Options」ヘッダーを外す

とにかくのYandexのツールmetrica.yandex.comだオプションは、私は

それを使用しようとしたときに訪問者がクリックしてウェブサイト上のほとんどの場所を示した地図を呼ば提供します

エラーメッセージが表示されます。

Not possible to replay visit on the given page. Possible reasons: 
Counter code not configured 
Displaying this page in a frame is forbidden 

そして、私はかなり良いカウンターコードが設定されていることを確信しています。私はヘルプページのリンクを訪れたので、正しい場所に置いておきました:yyex.com/support/metrica/behavior/click-map.html

問題だものを見るために私は

If your site is protected from being shown in an iframe (the X-Frame-Options header is used in the server settings), the collected data won't be available for viewing. To view the site's session data, you must change the server settings and add an exception for the webvisor.com domain and subdomains, as well as for your site's domain. Use the regular expression 

、彼らが使用するユーザーに与えるが、マップの仕事をするために設定ファイルに追加する必要があり、コードをnginxのことがわかっ正しく

ので、Iこれを追加しました。これは私の設定ファイルで、2行追加した後です

.....  
server_name _; 
      location/{ 
        # First attempt to serve request as file, then 
        # as directory, then fall back to displaying a 404. 
        try_files $uri $uri/ =404; 
        set $frame_options ''; 
        if ($http_referer !~ '^https?:\/\/([^\/]+\.)?(www.google\.com|webvisor\.com)\/'){ 
        set $frame_options 'SAMEORIGIN'; 
      } 
        add_header X-Frame-Options $frame_options; 
    } 
..... 

私はwww.google.com

と私のドメイン名を変更したが、まだ私はなぜ知らないが、多分私はいくつかのステップを逃した私に見せてエラーが...みんなは私に可能性を提案してください解決策私はこのオプションを多く必要とし、広告をどこに置くことができるかを知るために

+1

ポスト完全nginxの設定ファイル –

答えて

1

私は最近Yandex Metricaで同じ問題に遭遇しました。私の場合は原因がContent-Security-Policyの設定であり、X-Frame-Optionsではないので、エラーメッセージは少し誤解を招く。 Installing a counter on a site with CSPのためのマニュアルをチェックし、nginxの構成に以下のようなものを追加しよう: `nginxの-T`の出力から

add_header  Content-Security-Policy "frame-src blob: https://mc.yandex.ru https://mc.yandex.com https://mc.webvisor.com https://mc.webvisor.org"; 
add_header  Content-Security-Policy "child-src blob: https://mc.yandex.ru https://mc.yandex.com https://mc.webvisor.com https://mc.webvisor.org"; 
add_header  Content-Security-Policy "script-src 'unsafe-inline' https://yastatic.net https://mc.yandex.ru https://mc.yandex.com 'self'"; 
関連する問題