2017-09-20 20 views
0

iframeにいくつかのサイトを表示する必要があり、それらのサイトの一部にX-Frame-Optionsヘッダーが 'SAMEORIGIN'に設定されているため、直接行うことはできません。これをバイパスする方法として、私はApacheのリバースプロキシを使ってみました。以下は私のApacheの設定次のプロキシがX-Frame-Optionsヘッダーをバイパスしないのはなぜですか?

<VirtualHost *:80> 
ServerName google.local 
ProxyRequests Off 

DocumentRoot /var/www/html/iframe-test 

ProxyPass /test http://www.oracle.com/index.html 
ProxyPassReverse /test http://www.oracle.com/index.html 

ErrorLog /var/log/apache2/google.local-error.log 
CustomLog /var/log/apache2/google.local-access.log combined 

<Location *> 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
    # Header always append X-Frame-Options "ALLOW-FROM all" 
    Header add test-header 'test' 
</Location> 

しかし、それでもまだ、私はiframe内にサイトを読み込むことができないと私は上記構成の問題は、プロキシのみのために働いていたということでしたエラーにLoad denied by X-Frame-Options: https://www.oracle.com/index.html does not permit cross-origin framing.

答えて

0

を取得していますですhttpプロトコル。しかし、コンソールのエラーメッセージに見られるように、外部サイトは実際にhttpを自動的にhttpsにリダイレクトします。
https要求を処理するには、Apacheでsslを有効にしてSSLProxyEngineを有効にする必要がありました。ターミナル

    1. 実行sudo a2enmod ssl、ということを行うには

      <VirtualHost *:80> 
          ServerName google.local 
      
          ProxyRequests On 
          ProxyPreserveHost Off 
          SSLProxyEngine On 
      
          DocumentRoot /var/www/html/iframe-test 
      
          ProxyPass /test http://www.oracle.com/index.html 
          ProxyPassReverse /test http://www.oracle.com/index.html 
      
          ErrorLog /var/log/apache2/google.local-error.log 
          CustomLog /var/log/apache2/google.local-access.log combined 
      
          <Location *> 
           AllowOverride All 
           Order allow,deny 
           Allow from all 
           # Header always append X-Frame-Options "ALLOW-FROM all" 
           Header add test-header 'test' 
          </Location> 
      </VirtualHost> 
      
    上記の設定にライン 'SSLProxyEngineで' を追加します
  • 関連する問題