首页 > nginx根据不同ip请求不同文件配置

nginx根据不同ip请求不同文件配置

    location / {
        if ($remote_addr ~ "120.11.74.18")
            {
                alias $rootdir1;
                 break;
            }
        alias $rootdir2;
    }

nginx: [emerg] "alias" directive is not allowed here in /home/rocky/nginx/conf.d/test.conf:14
nginx: configuration file /home/rocky/nginx/conf/nginx.conf test failed


用变量

location / {
        set $rootdir "path/to/a";
        if ($remote_addr ~ "120.11.74.18")
            {
                set $rootdir "path/to/b";
            }
        alias $rootdir;
    }
【热门文章】
【热门文章】