nginx配置从远程获取静态资源
Posted danger0us
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx配置从远程获取静态资源相关的知识,希望对你有一定的参考价值。
前置条件:现有两台内网互通机器192.168.0.100、192.168.0.101,其中192.168.0.100可以通过外网网络。
业务需求:需要通过外网访问处于192.168.0.101机器上的静态资源。
192.168.0.100nginx配置:
location /upload {
alias /data/image/upload;
try_files $uri @new_server;
}
location @new_server {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.0.101:80;
}
192.168.0.101nginx配置:
location /upload {
alias /data/image/upload;
}
以上是关于nginx配置从远程获取静态资源的主要内容,如果未能解决你的问题,请参考以下文章