[以下でLaravel側で色々設定する方法あるがNginx側で[SAMEORIGIN]設定されていると]どうやっててもSAMEORIGINが勝って(優先されて)しまうようだ
X-Frame-Options レスポンスヘッダーの設定を変更すれば表示すると思います。変更可能でしょうか?
iframe内からWebページが読み込まれるのを防止する X-Frame-Options HTTP レスポンスヘッダ
https://buzzwordjp.blogspot.com/2011/09/iframe-x-frame-options-http.html
laravelでは通常(何も考えずに実装すると)
X-Frame-Optionsの設定によりiframeからは読み込めない設定になっている
laravelでX-Frame-Optionsを AllOWにする方法
middlewareでFROMURLも指定してALLOW
Set your header on the response from the frame to
X-Frame-Options: ALLOW-FROM https://example.com/
where example.com is the domain requesting the form.
You could use middleware in laravel to do this.
Generate a new middleware.
php artisan make:middleware FrameHeadersMiddleware
then in the handle function of the middleware you just created do something like:
namespace App\Http\Middleware;
use Closure;
public function handle($request, Closure $next)
{
$response = $next($request);
$response->header('X-Frame-Options', 'ALLOW FROM https://example.com/');
return $response;
}
You can then add this to one of the middleware arrays in Kernel.php
protected $middleware = [
App\Http\Middleware\FrameHeadersMiddleware::class
];
Or to one of the middleware group arrays if you want to add it only to specific routes.
すべてのURLからのリクエストを許可する場合
class FrameHeadersMiddleware { public function handle($request, Closure $next) { $response = $next($request); //$response->header('X-Frame-Options', 'ALLOWALL'); //$response->header('X-Frame-Options', 'ALLOW FROM https://www.facebook.com'); $response->headers->set('X-Frame-Options', '*'); return $response; } }
その他色々ヘッダーを修正する方法
webサーバ(nginx)で設定する方法
https://stackoverflow.com/questions/44436659/change-the-x-frame-options-to-allow-all-domains
So, I read that you can allo a specific domain by adding this lint to the /etc/nginx/nginx.conf
:
add_header X-Frame-Options “ALLOW-FROM https://subdomain.example.com/”;
コントローラで指定する方法
https://laracasts.com/discuss/channels/laravel/iframe-and-x-frame-options?page=1
return view(‘front.benefits’) ->withHeaders(‘X-Frame-Options’, ‘ALLOWALL’) ->with(‘somedata’, $somedata);