[英]How to map a certain URL in nginx to an external website
I would like to download a file hosted on an external CDN whenever the user hits a particular URL in my website. 每当用户点击我网站上的特定网址时,我都想下载托管在外部CDN上的文件。
For ex. 对于前者 I have a certain file hosted at https://asset.mycdn.com/file.exe ;
我有一个托管在https://asset.mycdn.com/file.exe的文件;
Now when the user hits the URL https://www.mywebsite.com/download , then it should automatically download the file hosted at https://asset.my-cdn.com/file.exe . 现在,当用户点击URL https://www.mywebsite.com/download时 ,它应该自动下载https://asset.my-cdn.com/file.exe上托管的文件。
Add following in your nginx settings : 在你的nginx设置中添加以下内容:
location ^/download {
return 301 https://asset.my-cdn.com/file.exe;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.