2016-10-22 90 views
2
获取数据

我正在使用第三方API在公共URL上向我们提供数据。我希望这些数据在我的网站上,而用户不知道数据从何处获取的确切位置。隐藏网站的URL我从

实施例: 数据从该URL中获取:https://example.com/1477116779.16443511_0.mp3 数据将被显示在此:www.zigsaw.in/telephonicinterviews/1477116779.16443511_0.mp3

我试图使用的IFrame

<iframe src="https://example.com/1477116779.16443511_0.mp3" width="100%" height="100%" frameborder="0" scrolling="no" /> 

,但它允许“在新标签页中打开链接”,从而显示原始页面源

背景:我们是一家招聘启动公司,不想让外面的人知道我们的小jugaad 。最终,他们会知道,但我更喜欢3-4个月的头马。

P.S. :下载数据&上传到我的服务器上也是一个解决方案,但我不想不必要的负担我的托管。由于这些是音频文件,因此占用大量空间。

回答

2

没有为这个问题没有HTML的解决方案 - 您可以将URL改写为您的服务器,但你需要一个脚本,该脚本获取原始URL并显示数据 - 这样的事情:

<?php 
header('Content-disposition: attachment; filename=filename.mp3'); 
header('Content-type: application/octet-stream'); // adjust this to your real fileType 
header('Content-type: audio/mpeg'); // use this for mp3 
echo file_get_content('http://your-url.com/123'); 
?> 

然后链接到这个脚本 - 瞧 - 用户只能看到你的网址,而不是原来的网址。脚本正在传递数据。

+0

效果很好。谢谢:) 任何想法如何播放音频&不强制用户下载它? –

+0

请参阅我的编辑内容 - 使用其他内容类型“audio/mpeg”。 – cklm

+0

它还在下载 –

1

您可以禁用右键点击元素,虽然这不会阻止某人看到inspect element选项卡中的网址,甚至不能在原始html/page source页面中查看它。

因此,要禁用右键单击iframe元素,请使用此选项。 (1键是正常点击,2是右键。)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
<script> 
    $("iframe").click(function(event) { 
     if(event.button==2) { 
      return false;  
     } 
    }); 
</script> 
1

如果您使用的Nginx作为你可以在代理服务器级别的请求您的Web服务器。创建一个充当API代理的子域。

配置简单:

http { 
    sendfile  on; 

    keepalive_timeout 2000; 

    server { 
     listen  80; 
     server_name data.example.com; 

     location/{ 
      proxy_pass https://www.zigsaw.in; 
      proxy_pass_request_body on; 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     } 
    } 
} 

阅读Nginx的文档,了解有关ngx_http_proxy_module进一步的细节。