Ocelot: Bad Request with Ocelot ReRoute using Eureka as Service Provider at LocalHost
Expected Behavior
Reroute to /api/User/GetStuff
Actual Behavior
Bad Request - Invalid Hostname HTTP Error 400. The request hostname is invalid.
Steps to Reproduce the Problem
Project Link: https://github.com/JayChuah95/AntyChatty/tree/master/AntyChatty
- Startup multiple project and go to url ‘localhost:10000/Auth/GetStuff’
My ocelot.json
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/User/GetStuff",
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/Auth/GetStuff",
"UseServiceDiscovery": true,
"ServiceName": "AuthService",
"UpstreamHttpMethod": [ "Get" ]
},
{
"DownstreamPathTemplate": "/api/User/GetAuthorize",
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/Auth/GetAuthorize",
"UseServiceDiscovery": true,
"ServiceName": "AuthService",
"UpstreamHttpMethod": [ "Get" ],
"AuthenticationOptions": {
"AuthenticationProviderKey": "ApiSecurity",
"AllowedScopes": []
}
}
],
"GlobalConfiguration": {
"RequestIdKey": "OcRequestId",
"AdministrationPath": "/administration",
"ServiceDiscoveryProvider": {
"Type": "Eureka",
"Host": "localhost",
"Port": "8761"
}
}
}
AuthService appsettings.json
{
"spring": {
"application": {
"name": "AuthService"
}
},
"eureka": {
"client": {
"serviceUrl": "http://localhost:8761/eureka",
"shouldRegisterWithEureka": true,
"shouldFetchRegistry": true,
"validateCertificates": false
},
"instance": {
"port": 20000
}
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"AppSettings": {
"Secret": "0265776e-b490-4253-9be4-7d73457700b1"
}
}
Specifications
- NuGet: Ocelot 13.5.2, Ocelot.Provider.Eureka 13.5.2, Steeltoe.Discovery.ClientCore 2.3.0
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 16 (7 by maintainers)
Temperary Solution go to .vs\config and change the applicationhost.config Modify from
<binding protocol="http" bindingInformation="*:20000:localhost" />
to<binding protocol="http" bindingInformation="*:20000:*" />