1、返回状态码
return 404;
location /test { set $name 'user123'; return 404 $name; } curl -i http://192.168.56.10/test
2、返回字符串(不过输出结果并未见到 状态码后的字符串输出)
return 200 ‘hello’;
location /test { return 200 'hello'; } curl -i http://192.168.56.10/test
3、地址跳转
return http://www.baidu.com;
location /test { return http://www.baidu.com; } curl -i http://192.168.56.10/test http://192.168.56.10/test
4、返回自定义变量
set $name 'user123'; return 200 $name;
5、返回内置变量
return $uri;
6、返回日志信息实例
return 200 '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';