Giter Site home page Giter Site logo

router supprot? about slardar HOT 9 OPEN

liuyangc3 avatar liuyangc3 commented on July 23, 2024
router supprot?

from slardar.

Comments (9)

yejingx avatar yejingx commented on July 23, 2024

Change skey to ngx.var.uri.

from slardar.

liuyangc3 avatar liuyangc3 commented on July 23, 2024

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.

jiangsuwwj1 avatar jiangsuwwj1 commented on July 23, 2024

@yejingx

How to change skey to ngx.var.uri

from slardar.

yejingx avatar yejingx commented on July 23, 2024

How to change skey to ngx.var.uri

Replace this line with local skey = ngx.var.uri

from slardar.

jiangsuwwj1 avatar jiangsuwwj1 commented on July 23, 2024

非常感谢,另外最近在使用以及在对slardar做一些改造的时候遇到一些问题,能否加一下微信方便沟通呢?我微信号是:jiangsuwwj
thank you very much, recently i encountered some problem when using 'slardar', could you leave a contact for communicating?

from slardar.

yejingx avatar yejingx commented on July 23, 2024

@jiangsuwwj1 我的邮箱: [email protected]

from slardar.

jiangsuwwj1 avatar jiangsuwwj1 commented on July 23, 2024

@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.

yejingx avatar yejingx commented on July 23, 2024

如何设置默认的动态代理呢?

要做到『默认』是否要考虑 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.

jiangsuwwj1 avatar jiangsuwwj1 commented on July 23, 2024

@yejingx 明白了,多谢

from slardar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.