找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 888|回复: 0

Nginx Return指令使用

[复制链接]

296

主题

38

回帖

1274

积分

管理员

积分
1274
发表于 2021-4-16 17:39:46 | 显示全部楼层 |阅读模式
#Return指令使用:
1.返回状态码
return 404;

2.返回字符串
return 200 'hello';

3.地址跳转
return http://www.baidu.com;

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"';

7.curl测试
curl http://192.168.2.1/test?id=10 -H "referer: 192.168.1.1" -H "x-forwarded-for: 192.168.3.3"

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|外汇论坛 ( 粤ICP备16021788号 )

GMT+8, 2024-5-18 15:27 , Processed in 0.069293 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表