gpt4 book ai didi

linux - 在Nginx上服务外部文件

转载 作者:行者123 更新时间:2023-12-03 10:01:26 25 4
gpt4 key购买 nike

我想从Nginx服务器提供一个外部文件,就像要获取一个文件并在try_files上提供服务,像这样

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

那可能吗?

最佳答案

try_files指令只能接受内部URI作为最后一个参数。

但是,您也可以使用命名位置作为最后一个参数,并将外部URL放置在该位置。有关详细信息,请参见this document

例如:

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

关于linux - 在Nginx上服务外部文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59772929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com