location / {
# 网站镜像
# 此时 root /var/www/html; 的内容不会再显示
# limit_req zone=mylimit; # 启用限制
# 先定义好要 mirror 的网站以及自己的网站
set $upstream_server http://mirror_domain.tld;
set $upstream_domain mirror_domain.tld;
set $mydomain
example.com;
# use variable to avoid resoling failure that leads to start nginx failure
# refer:
https://sandro-keil.de/blog/let-nginx-start-if-upstream-host-is-unavailable-or-down/ sub_filter_once off;
sub_filter_types *;
sub_filter $upstream_domain $mydomain;
proxy_set_header Referer $upstream_server;
proxy_set_header Host $upstream_domain;
proxy_pass $upstream_server;
}