2015-12-10 12 views
2

我用nginx的X框-選項具有相同值的

add_header X-Frame-Options SAMEORIGIN;

在nginx的,但是當我除去它仍然;它仍然是我不能在我的網站使用iframe和相同的價值得到了以下錯誤:

Refused to display 'xxx' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

刪除此配置並重新啓動兩個nginx的和PHP-FPM,試圖

add_header X-Frame-Options "ALLOWALL";

Nginx的配置:

server { 
    server_tokens off; 
    access_log off; 
    listen 80 default; 
    server_name www.example.com *.example.com; 
    root /var/www/vhosts/example.com; 

    location/{ 
     index index.html index.php; 
     try_files $uri $uri/ @handler; 
     expires 30d; 
     if (!-e $request_filename) { 
        rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last; 
      } 
    } 

    set $ssl "off"; 
    if ($http_x_forwarded_proto = "https") { 
    set $ssl "on"; 
    } 


    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { 
     access_log  off; 
     log_not_found  off; 
     expires   30d; 
    } 


    location @handler { 
     rewrite//index.php; 
            } 

    location ~ .php/ { 
     rewrite ^(.*.php)/ $1 last; 
    } 

    location ~ .php$ { 
     if (!-e $request_filename) { rewrite//index.php last; } 

     expires  off; 
     fastcgi_pass unix:/var/run/php-fpm/example.sock; 
     fastcgi_param HTTPS $fastcgi_https; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param MAGE_RUN_CODE default; 
     fastcgi_param MAGE_RUN_TYPE store; 
     fastcgi_buffer_size 1024k; 
     fastcgi_buffers 512 32k; 
     fastcgi_busy_buffers_size 1024k; 
     fastcgi_temp_file_write_size 1024k; 

     include  fastcgi_params; ## See /etc/nginx/fastcgi_params 
    } 
} 

與檢查元件檢查時在頭下面實測值:

X-Frame-Options:ALLOW-FROM https://www.youtube.com/ 
X-Frame-Options:SAMEORIGIN 

所以有X框架選項以某種方式添加,但無法找到它

+0

你的問題是什麼? –

+0

爲什麼即使在從nginx配置中刪除x-frame-options之後,我得到了低於錯誤的錯誤? >拒絕在框架中顯示'xxx',因爲它將'X-Frame-Options'設置爲'SAMEORIGIN'。 – MahmoudMustafa

+0

你應該發佈你的nginx配置 –

回答

1

我能弄明白我自己。我所做的是,當我看到它不起作用時,我在.html文件中做了一個快速更改並保存。之後,它的工作。

例如: 我有一個在nginx上運行的文件,比如index.html。我刪除了add_header X-Frame-Options DENY;nginx.conf,重新啓動服務器,但沒有運氣。它一直否認。它的行爲完全沒有改變,而改變就在那裏。我所做的是,我在index.html中更改了一行(或者只是增加了一個空格,只是做了任何更改),保存了更改,然後重新啓動了服務器,然後...... voila:工作!

+1

我遇到了這個問題,NGINX顯示標題選項被設置爲拒絕,但仍然在iFrame內部服務頁面。我編輯了index.html並重新啓動了nginx,它突然生效。希望有人能夠衡量這一點。謝謝! – borislemke

+0

我猜nginx提供文件的緩存版本,直到它檢測到文件中有任何更改,並且頭文件已經連接到緩存版本。 –