简体   繁体   English

在 nginx 上提供外部文件

[英]Serve external file on nginx

I want to deliver a external file from a nginx server, something like to wget a file and serve on try_files, something like this我想从 nginx 服务器提供一个外部文件,比如 wget 一个文件并在 try_files 上提供服务,就像这样

location / {
    try_files $uri $uri/ http://externalurl.com/index.html;
}

Is that possible?那可能吗?

The try_files directive can only accept an internal URI as the last parameter. try_files指令只能接受内部 URI 作为最后一个参数。

However, you can also use a named location as the last parameter, and place your external URL there.但是,您也可以使用命名位置作为最后一个参数,并将外部 URL 放在那里。 See this document for details.有关详细信息,请参阅此文档

For example:例如:

location / {
    try_files $uri $uri/ @redirect;
}
location @redirect {
    return 302 http://externalurl.com/index.html;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM