File tree Expand file tree Collapse file tree 5 files changed +75
-48
lines changed Expand file tree Collapse file tree 5 files changed +75
-48
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ application name必须全小写,context-path需要与application name相同,
3030## 配置和启动ngineureka
3131下载ngineureka.zip或自行编译
32321.1版本后,由于springcloud编译出的文件较大,已放到网盘
33+
3334v1.2:
3435https://pan.baidu.com/s/1USs4gBNIlx0KBMxUCD-u-A
3536
@@ -42,6 +43,12 @@ https://pan.baidu.com/s/1RlKr9Z8f0Tm89uMlrRZwSg
4243
4344[ linux下配置和启动] [ 4 ]
4445
46+ ### 可选的配置
47+
48+ ngineureka还提供了一些可选的配置,方便您针对某个应用进行特殊配置:
49+
50+ [ 可选配置] [ 6 ]
51+
4552## RESTful API
4653
4754```
@@ -60,8 +67,9 @@ http://localhost:10001/ngineureka/
6067![ 此处输入图片的描述] [ 5 ]
6168
6269
63- [ 1 ] : http ://7xlvcv.com1.z0.glb.clouddn. com/01bbc543-059f-4f2a-8364-dd95a7505deb
70+ [ 1 ] : https ://camo.githubusercontent. com/26621f8cb95a1f4d139e974a7e81680b994546c0/687474703a2f2f37786c7663762e636f6d312e7a302e676c622e636c6f7564646e2e636f6d2f30316262633534332d303539662d346632612d383336342d646439356137353035646562
6471 [ 2 ] : https://pan.baidu.com/s/1RlKr9Z8f0Tm89uMlrRZwSg
6572 [ 3 ] : https://github.com/codingmiao/ngineureka/blob/master/wincfg.md " windows下配置和启动 "
6673 [ 4 ] : https://github.com/codingmiao/ngineureka/blob/master/linuxcfg.md " linux下配置和启动 "
67- [ 5 ] : http://7xlvcv.com1.z0.glb.clouddn.com/9fffa1d7-5116-4149-911e-0656f90bca4b
74+ [ 5 ] : http://7xlvcv.com1.z0.glb.clouddn.com/9fffa1d7-5116-4149-911e-0656f90bca4b
75+ [ 6 ] : https://github.com/codingmiao/ngineureka/blob/master/optional.md " 可选配置 "
Original file line number Diff line number Diff line change 55eureka:
66 client:
77 serviceUrl:
8- defaultZone: http://10.111.58.121 :10000/eureka/
8+ defaultZone: http://127.0.0.1 :10000/eureka/
99server:
1010 tomcat:
1111 uri-encoding: UTF-8
@@ -68,29 +68,14 @@ reload.sh文件如下:
6868修改第一行,使得sh命令能够切换到您的nginx根目录
6969通过chmod命令,赋予reload.sh文件执行权限
7070
71- ## 可选操作1、为location块添加参数(自版本1.1.1)
72- 有时候,我们需要对location块添加一下参数,以满足性能,安全性等需求,比如:
73- ```
74- location ^~ /xx/ {
75- proxy_pass http://upstream_xx;
76- deny 192.168.1.2;
77- deny 192.168.1.3;
78- }
79- ```
80- 此时,我们可以配置根目录下的文件locationParam.txt(没有则新建一个)
81- ```
82- >xx
83- deny 192.168.1.2;
84- deny 192.168.1.3;
85-
86- >xx1
87- proxy_set_header X-Real-IP $remote_addr;
88- ```
89- ">"开头的行表示应用名称,根据前面的约定,会被转为全小写
90- 下面跟着的行就是该应用对应的location块下要加的参数了
91-
9271## 4、启动
9372./startup.sh启动服务
9473您可以通过查看{confPath}/ngineureka_upstream.conf文件,检查配置信息是否正确地添加到nginx
9574
75+ 执行curl命令,或直接在浏览器访问下面的地址,手动刷新一下服务
76+ ```
77+ curl http://127.0.0.1:10001/ngineureka/cmd/reload
78+
79+ ```
80+
9681然后,就能通过nginx,访问到您的rest服务了~
Original file line number Diff line number Diff line change 1+ # 可选的配置
2+
3+ ngineureka还提供了一些可选的配置,方便您针对某个应用进行特殊配置。
4+
5+ 这些配置都是初始化时加载到内存中的,所以如果您修改了这些文件,需要重启ngineureka方可生效
6+
7+ ## 1、为location块添加参数(自版本1.1.1)
8+
9+ 有时候,我们需要对location块添加一下参数,以满足性能,安全性等需求,比如:
10+ ```
11+ location ^~ /xx/ {
12+ proxy_pass http://upstream_xx;
13+ deny 192.168.1.2;
14+ deny 192.168.1.3;
15+ }
16+ ```
17+ 此时,我们可以配置根目录下的文件locationParam.txt(没有则新建一个)
18+ ```
19+ >xx
20+ deny 192.168.1.2;
21+ deny 192.168.1.3;
22+
23+ >xx1
24+ proxy_set_header X-Real-IP $remote_addr;
25+ ```
26+ ">"开头的行表示应用名称,根据前面的约定,会被转为全小写
27+ 下面跟着的行就是该应用对应的location块下要加的参数了
28+
29+ ## 2、为某个应用指定负载均衡策略(自版本1.2.1)
30+
31+ ngineureka默认采用最小连接数策略(least_conn)进行负载均衡
32+
33+ 有时候,我们需要指定某个应用的负载均衡策略,例如应用myApp有一个服务地址
34+ ```
35+ /myApp/getUser/<UserId>
36+ ```
37+ 并且在应用内部,我们将查询结果以UserId作为key进行缓存,为了提高缓存命中率,我们此时可选择url_hash策略,将相同的id转发到相同的节点上:
38+ 配置根目录下的文件loadBalancingStrategy.properties(没有则新建一个)
39+ ```
40+ myapp=url_hash
41+ ```
42+
43+ 支持的负载均衡策略如下:
44+
45+ - least_conn 默认,最小连接数
46+ - ip_hash 通过客户端请求ip进行hash,再通过hash值选择后端server
47+ - polling 轮询
48+ - url_hash 通过请求url进行hash,再通过hash值选择后端server(部分版本的nginx需安装对应模块)
49+ - fair 按后端服务器的响应时间来分配请求,响应时间短的优先分配(部分版本的nginx需安装对应模块)
Original file line number Diff line number Diff line change 22# least_conn 默认,最小连接数
33# ip_hash 通过客户端请求ip进行hash,再通过hash值选择后端server
44# polling 轮询
5- # url_hash 通过请求url进行hash,再通过hash值选择后端server(需安装对应模块 )
6- # fair 按后端服务器的响应时间来分配请求,响应时间短的优先分配(需安装对应模块 )
5+ # url_hash 通过请求url进行hash,再通过hash值选择后端server(部分版本的nginx需安装对应模块 )
6+ # fair 按后端服务器的响应时间来分配请求,响应时间短的优先分配(部分版本的nginx需安装对应模块 )
77# 示例 myapp=url_hash 表示名称为myapp的这个应用使用url_hash策略
88ngineureka =polling
Original file line number Diff line number Diff line change 55eureka:
66 client:
77 serviceUrl:
8- defaultZone: http://10.111.58.121 :10000/eureka/
8+ defaultZone: http://127.0.0.1 :10000/eureka/
99server:
1010 tomcat:
1111 uri-encoding: UTF-8
@@ -67,29 +67,14 @@ nginx -s reload
6767```
6868修改前两行,使得cmd命令能够切换到您的nginx根目录
6969
70- ## 可选操作1、为location块添加参数(自版本1.1.1)
71- 有时候,我们需要对location块添加一下参数,以满足性能,安全性等需求,比如:
72- ```
73- location ^~ /xx/ {
74- proxy_pass http://upstream_xx;
75- deny 192.168.1.2;
76- deny 192.168.1.3;
77- }
78- ```
79- 此时,我们可以配置根目录下的文件locationParam.txt(没有则新建一个)
80- ```
81- >xx
82- deny 192.168.1.2;
83- deny 192.168.1.3;
84-
85- >xx1
86- proxy_set_header X-Real-IP $remote_addr;
87- ```
88- ">"开头的行表示应用名称,根据前面的约定,会被转为全小写
89- 下面跟着的行就是该应用对应的location块下要加的参数了
90-
9170## 4、启动
9271双击startup.bat启动服务
9372您可以通过查看{confPath}/ngineureka_upstream.conf文件,检查配置信息是否正确地添加到nginx
9473
74+ 在浏览器访问下面的地址,手动刷新一下服务
75+ ```
76+ http://127.0.0.1:10001/ngineureka/cmd/reload
77+
78+ ```
79+
9580然后,就能通过nginx,访问到您的rest服务了~
You can’t perform that action at this time.
0 commit comments