Nginx 重定向到https所有用户代理,而不是指定的一个

Nginx 重定向到https所有用户代理,而不是指定的一个,nginx,Nginx,如果nginx检测到用户代理为“someAgentX”,不要重定向到https,保持在IP上。其他代理重定向到https。 像这样的东西,但这不起作用 server { listen 80; root /www; if ($http_user_agent ~* "someAgentX") { return 1; } return 301 https://$host$request_uri; } server { ..and there is ssl c

如果nginx检测到用户代理为“someAgentX”,不要重定向到https,保持在IP上。其他代理重定向到https。 像这样的东西,但这不起作用

server {
  listen 80;
  root /www;

  if ($http_user_agent ~* "someAgentX")
  {
       return 1;
  }
  return 301 https://$host$request_uri;
}

server {
 ..and there is ssl config etc.
}
完成了,现在开始工作了

完成了,现在开始工作了

  if ($http_user_agent != "someAgentX")
  {
    return 301 https://$host$request_uri;
  }