In a server directive for port 80 in nginx I want to redirect all requests to https **if** the user agent is not a bot. I tried using this:

```
...
location / {
    if ($http_user_agent !~* (bot|spider|crawler|sniffer|facebook) ) {
        return 301 https://host.com$request_uri;
    }

    include other-stuff.inc;
}

```

I thought nginx would stop on the `return` but it doesn't. It still processes the `include` (which serves the normal site) and does not redirect. (If I comment the `include` it does the redirect, though).