Nginx proxy nginx.conf configuration - nginx proxy for static files

1. Proxy static resources in the root directory

Nginx proxy nginx.conf configuration - reverse proxy

2. Directory Agent

If you need to proxy resources to different directories, configure the following under the server node in nginx.conf:

location /image {
    root /opt/cache;
}

location vedio {
    root /opt/cache;
}

After modification, just reload the nginx configuration. Some nginx commands are as follows:

# 检查配置
nginx -t
# 重载配置
nginx -s reload
# 关闭
nginx -s quit
# 启动
nginx -s start

3. Proxy static resources under the specified path

Add the following configuration to the server (the example listen port is 80)

location ~ /video/.*\.(mp4)?$ {
    expires -1;
    # 匹配结果示例:opt/cache/video/demo.mp4
    root /opt/cache;
}

Visit: localhost/video/demo.mp4 to access

Guess you like

Origin blog.csdn.net/pp_lan/article/details/131811477