我可以根据客户端 ip 在 nginx 上提供不同的文档根目录吗?基本上我希望使用相同的 url 为我的客户端 IP 提供不同的代码分支。
例如,这就是我期望的配置:
server {
listen 80;
server_name some.server.name;
client_max_body_size 10M;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json;
root {{ deploy_directory }};
location /robots.txt {}
if ($remote_addr ~ "^(<ip>|<ip>|<ip>)$") {
root <some other root>
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
log_not_found off;
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
break;
}
}
Run Code Online (Sandbox Code Playgroud)
但这没有加载
nginx ×1