Comments (9)
Change skey to ngx.var.uri
.
from slardar.
thanks your reply, how to deal with some uri like these config
server_name www.abc.com;
location ~ /.*\.jsp$ { proxy_pass up1 }
location ~ /.*\.html$ { proxy_pass up2 }
location ~ /begin/(path1)|(path2)/.*\.action$ { proxy_pass up3 }
in location case 3, it will be very hard to write the skey.
from slardar.
How to change skey to ngx.var.uri
from slardar.
How to change skey to ngx.var.uri
Replace this line with local skey = ngx.var.uri
from slardar.
非常感谢,另外最近在使用以及在对slardar做一些改造的时候遇到一些问题,能否加一下微信方便沟通呢?我微信号是:jiangsuwwj
thank you very much, recently i encountered some problem when using 'slardar', could you leave a contact for communicating?
from slardar.
@jiangsuwwj1 我的邮箱: [email protected]
from slardar.
@yejingx 收到,另外这里还有一个问题想要问一下。如何设置默认的动态代理呢?这里举个例子:
例:)
Nginx作为负载均衡器,IP为192.168.122.1监听端口80,访问http://192.168.122.1自动代理到后端server,以下是Nginx的配置。
http {
...
upstream backend {
server 192.168.122.173:8080 weight=1 max_fails=3 fail_timeout=3;
server 192.168.122.65:8080 weight=1 max_fails=3 fail_timeout=3;
...
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://backend;
}
...
}
如果用slardar动态负载来做的话, 该怎么做呢? 我这里考虑了几种方案,不知道对不对,
第一种方案:使用Host来区分,默认slardar使用Host也就是域名来找到对应的服务,这里追加域名指向nginx 服务器,然后追加一条consul记录, key为域名。
第二种方案:使用IP来区分,这里追加一条consul记录,key为nginx的IP也就是192.168.122.1。
不知道以上的理解对不对, 另外想问一下是否还有更好的解决方案呢?
from slardar.
如何设置默认的动态代理呢?
要做到『默认』是否要考虑 Host 为空和 Host 不在你的列表里两种情况?
如果是的话,建议在 balancer.lua 里做修改:
local my_hosts = {
hostA = 1,
hostB = 1,
hostC = 1,
}
local skey = ngx.var.host
if not skey or not my_hosts[skey] then
skey = 'defalt_host'
end
同样地,用 ngx.var.uri
作为 skey 也是类似的做法。
from slardar.
@yejingx 明白了,多谢
from slardar.
Related Issues (20)
- Can't find variable HOT 2
- How to add upstream backup server in consul, Does it support? HOT 2
- Can not failover up to good server if one server down with consistent_hash method HOT 2
- How to apply different lua scripts to one host? HOT 2
- set_by_lua HOT 6
- Is there any reason for set `slardar` as a global variable in `init` phase ?
- The general heartbeet cannot set domain to host, only IP address is ok HOT 1
- The keepalive does not work
- Why consul.api use socket.http not lua-resty-http HOT 1
- banlance rule and show upstream HOT 2
- some question HOT 1
- when use ngx.socket.tcp, the function sslhandshake is a nil HOT 5
- I install slardar and run nginx but got this HOT 3
- router not working normally HOT 4
- slardar与OpenResty区别 HOT 1
- Stream based load balancing not working HOT 10
- 【请教】slardar 持久化数据的问题 HOT 2
- 通过HTTP API修改UPSTREAM不起作用 HOT 4
- nginx: [error] failed to initialize Lua VM HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slardar.