0

Zuul を使用して Spring Boot を介してリボン (負荷分散) を構成するのに助けが必要です。以下に私の設定があります。

最初に、現在のアーキテクチャと到達したいものを共有します。

  • ゲートウェイを備えたノードが 1 つあります (Spring Boot + zuul + リボン)
  • スケーラブルなサービスを展開する別のノードが 2 つあります

ズール構成:

zuul.routes.outlets.path=/outlets/**
zuul.routes.outlets.serviceId=outlets

outlets.ribbon.listOfServers=http://11.11.111.125:8092,http://11.11.111.126:8093
ribbon.eureka.enabled=false

あなたが見る限り、特別なことは何もありません。私のスケーラブルなサービスには次の構成があります。

@SpringBootApplication
@PropertySource
@RibbonClient(name = "outlets", configuration = RibbonClientConfiguration.class)
public class OutletsApplication {

    public static void main(String[] args) {
        SpringApplication.run(OutletsApplication.class, args);
    }
}

@Configuration
public class RibbonClientConfiguration {

    @Bean
    public IClientConfig config() {
        return new DefaultClientConfigImpl();
    }

    @Bean
    public IPing ribbonPing(IClientConfig config) {
        return new PingUrl();
    }
}

私が理解している限り、それはかなり一般的な構成です。

http://11.11.111.125:8092/outletsまたはに直接リクエストするとhttp://11.11.111.126:8093/outlets、すべて正常に機能します。

しかし、ゲートウェイにリクエストを送信すると、404 が返されます。ログに表示される内容は次のとおりです。

Matching pattern:/outlets/**
Returning cached instance of singleton bean 'ribbonRestClient'
Zone aware logic disabled or there is only one zone
outlets using LB returned Server: 11.11.111.126:8093 for request /
RestClient sending new Request(GET: ) http://11.11.111.126:8093/
Get connection: {}->http://11.11.111.126:8093, timeout = 2000
[{}->http://11.11.111.126:8093] total kept alive: 2, total issued: 0, total allocated: 2 out of 200
Getting free connection [{}->http://11.11.111.126:8093][null]
Stale connection check
CookieSpec selected: ignoreCookies
Auth cache not set in the context
Target auth state: UNCHALLENGED
Proxy auth state: UNCHALLENGED
Attempt 1 to execute request
Sending request: GET / HTTP/1.1
 >> "GET / HTTP/1.1[\r][\n]"
 >> "accept-language: ru,en-US;q=0.8,en;q=0.6[\r][\n]"
 >> "x-forwarded-host: localhost:8080[\r][\n]"
 >> "x-forwarded-proto: http[\r][\n]"
 >> "x-forwarded-prefix: /outlets[\r][\n]"
 >> "upgrade-insecure-requests: 1[\r][\n]"
 >> "Accept-Encoding: gzip[\r][\n]"
 >> "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8[\r][\n]"
 >> "user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36[\r][\n]"
 >> "Netflix.NFHttpClient.Version: 1.0[\r][\n]"
 >> "X-netflix-httpclientname: outlets[\r][\n]"
 >> "Host: 11.11.111.126:8093[\r][\n]"
 >> "Connection: Keep-Alive[\r][\n]"
 >> "[\r][\n]"
>> GET / HTTP/1.1
>> accept-language: ru,en-US;q=0.8,en;q=0.6
>> x-forwarded-host: localhost:8080
>> x-forwarded-proto: http
>> x-forwarded-prefix: /outlets
>> upgrade-insecure-requests: 1
>> Accept-Encoding: gzip
>> accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
>> user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
>> Netflix.NFHttpClient.Version: 1.0
>> X-netflix-httpclientname: outlets
>> Host: 11.11.111.126:8093
>> Connection: Keep-Alive
 << "HTTP/1.1 404 Not Found[\r][\n]"
 << "Server: Apache-Coyote/1.1[\r][\n]"
 << "Content-Type: text/html;charset=UTF-8[\r][\n]"
 << "Content-Language: ru[\r][\n]"
 << "Content-Length: 306[\r][\n]"
 << "Date: Mon, 04 Apr 2016 21:47:16 GMT[\r][\n]"
 << "[\r][\n]"
 Receiving response: HTTP/1.1 404 Not Found
 << HTTP/1.1 404 Not Found
 << Server: Apache-Coyote/1.1
 << Content-Type: text/html;charset=UTF-8
 << Content-Language: ru
 << Content-Length: 306
 << Date: Mon, 04 Apr 2016 21:47:16 GMT
 Connection can be kept alive indefinitely
 << "<html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Mon Apr 04 21:47:16 UTC 2016</div><div>There was an unexpected error (type=Not Found, status=404).</div><div>No message available</div></body></html>"

私が見る限り、サービスへのリクエストにはパス/アウトレットが含まれていません。または、リボン クライアントの構成が間違っている可能性がありますか?

そして、私はそれを修正する方法を知りません。

誰でも私を助けてもらえますか?

4

0 に答える 0