最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
nginx中 echo模块使用例子
时间:2014-09-04 编辑:简简单单 来源:一聚教程网
我这里在ubuntu下使用nginx,
查看nginx版本,nginx -V
nginx version: nginx/1.1.19
确保有nginx-echo模块
–add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-echo
接下来在ip.jpuyy.com中添加配置,返回客户端ip,同时在http头中也加返回客户端ip
server {
listen 80;
server_name ip.jpuyy.com;
location / {
root /usr/share/nginx/jpuyy.com;
index ip.html;
add_header X-Client-IP $remote_addr;
echo $remote_addr;
}
}
获取自己的ip地址
➜ ~ curl ip.jpuyy.com
183.195.128.xx
➜ ~ curl -I ip.jpuyy.com
HTTP/1.1 200 OK
Server: nginx/1.1.19
Date: Sat, 23 Aug 2014 05:24:03 GMT
Content-Type: application/octet-stream
Connection: keep-alive
X-Client-IP: 183.195.128.xx
或
curl -I ip.jpuyy.com | grep X-Client |sed ‘s/ //’ | cut -d: -f2
相关文章
- nginx安装到指定目录的教程 12-07
- Nginx配置如何区分PC或手机访问不同域名 10-31
- 全面解析Nginx到底能做什么 10-29
- Nginx的安装和多域名配置的实现方法 09-29
- nginx location 配置 正则表达式实例详解 07-11
- nginx配置多个站点共用80端口的解决方法 06-11