2 jiansva jiansva 于 2017.09.04 22:26 提问

请求nginx中的location配置问题 1C

server{
listen 84;
server_name _;
root /data/www/myweb/ts;
access_log /data/nginx_log/access.log access;

location ~ ^/(.*).ts$ {
    add_header Cache-Flag hit;
    try_files /$uri @tsvideo;
    try_files /$uri @tsvideo_new;
}

location @tsvideo {
    add_header Cache-Flag miss;
    proxy_store on;
    proxy_temp_path /data/www/myweb/ts;
    proxy_store_access user:rw group:rw all:rw;
    proxy_set_header Host v1.abc.com
    proxy_pass http://v1.abc.com
}

location @tsvideo_new {
    add_header Cache-Flag miss;
    proxy_store on;
    proxy_temp_path /data/www/myweb/ts;
    proxy_store_access user:rw group:rw all:rw;
    proxy_set_header Host v12.abc.com
    proxy_pass http://v12.abc.com
}

}

请问下如何修改成当访问v1.abc.com,指向的是@tsvideo,访问v12.abc.com指向的是
@tsvide_new

1个回答

zml_moxueli
zml_moxueli   2017.09.05 09:52

server {
listen 80;
server_name v1.abc.com;

    location @tsvideo {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass   http://localhost:8180;
    }
}

    server {
    listen       80;
    server_name v12.abc.com;

    location @tsvideo_new {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass   http://localhost:8180;
    }
}
Csdn user default icon
上传中...
上传图片
插入图片