ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.35k stars 1.63k forks source link

Under CentOS configuration.json is rewritten before the value #78

Closed geffzhang closed 7 years ago

geffzhang commented 7 years ago

I deployed an instance of Ocelot under centos, starting with the following configuration: { "ReRoutes": [ { "DownstreamPathTemplate": "/api/values", "DownstreamScheme": "http", "DownstreamHost": "10.125.32.121", "DownstreamPort": 5002, "UpstreamPathTemplate": "/api/values", "UpstreamHttpMethod": "get", "AdditionalRequestHeaderOptions": { "EnableAdditionRequestHeader": true, "RequestHeaders": [ { "Key": "IP", "Data": "127.0.0.1" } ] }, "AuthenticationOptions": { "Provider": "IdentityServer", "ProviderRootUrl": "http://10.125.32.121:5000", "RequireHttps": false, "ApiName": "api1", "AllowedScopes": [ "openid", "Profile", "offline_access" ], "ApiSecret": "myApiSecret" } } ],

"GlobalConfiguration": { "RequestIdKey": "RequestId", "AdministrationPath": "/admin", "IdentityServerRootUrl": "http://10.125.32.121:5000" } } Then I added some configuration as follows: { "ReRoutes": [ { "DownstreamPathTemplate": "/api/values", "DownstreamScheme": "http", "DownstreamHost": "10.125.32.121", "DownstreamPort": 5002, "UpstreamPathTemplate": "/api/values", "UpstreamHttpMethod": "get", "AdditionalRequestHeaderOptions": { "EnableAdditionRequestHeader": true, "RequestHeaders": [ { "Key": "IP", "Data": "127.0.0.1" } ] }, "AuthenticationOptions": { "Provider": "IdentityServer", "ProviderRootUrl": "http://10.125.32.121:5000", "RequireHttps": false, "ApiName": "api1", "AllowedScopes": [ "openid", "Profile", "offline_access" ], "ApiSecret": "myApiSecret" } }, { "DownstreamPathTemplate": "/api/FlowEngine/StartFlow", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/StartFlow", "UpstreamHttpMethod": "post" }, { "DownstreamPathTemplate": "/api/FlowEngine/SubmitTask", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/SubmitTask", "UpstreamHttpMethod": "post" }, { "DownstreamPathTemplate": "/api/FlowEngine/TerminateInstance", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/TerminateInstance", "UpstreamHttpMethod": "post" }, { "DownstreamPathTemplate": "/api/FlowEngine/DeliverToStaff", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/DeliverToStaff", "UpstreamHttpMethod": "post" }, { "DownstreamPathTemplate": "/api/FlowEngine/RollbackToActivity", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/RollbackToActivity", "UpstreamHttpMethod": "post" }, { "DownstreamPathTemplate": "/api/FlowEngine/GetTaskItems", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/GetTaskItems", "UpstreamHttpMethod": "get" }, { "DownstreamPathTemplate": "/api/FlowEngine/GetFinishItems", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/GetFinishItems", "UpstreamHttpMethod": "get" }, { "DownstreamPathTemplate": "/api/FlowEngine/GetProcessToken", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/GetProcessToken", "UpstreamHttpMethod": "get" }, { "DownstreamPathTemplate": "/api/FlowEngine/GetInstanceById", "DownstreamScheme": "http", "DownstreamHost": "10.123.10.44", "DownstreamPort": 21164, "UpstreamPathTemplate": "/api/FlowEngine/GetInstanceById", "UpstreamHttpMethod": "get" } ],

"GlobalConfiguration": { "RequestIdKey": "RequestId", "AdministrationPath": "/admin", "IdentityServerRootUrl": "http://10.125.32.121:5000" } } Often a strange thing is that during the operation of Configuration.json into the previous file content {"ReRoutes":[{"DownstreamPathTemplate":"/api/values","UpstreamPathTemplate":"/api/values","UpstreamHttpMethod":"get","AuthenticationOptions":{"Provider":"IdentityServer","ProviderRootUrl":"http://10.125.32.121:5000","ApiName":"api1","RequireHttps":false,"AllowedScopes":["openid","Profile","offline_access"],"ApiSecret":"myApiSecret"},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":"","FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":"","DownstreamScheme":"http","DownstreamHost":"10.125.32.121","DownstreamPort":5002,"QoSOptions":{"ExceptionsAllowedBeforeBreaking":0,"DurationOfBreak":0,"TimeoutValue":0},"LoadBalancer":"","RateLimitOptions":{"ClientWhitelist":[],"EnableRateLimiting":false,"Period":"","PeriodTimespan":0.0,"Limit":0},"AdditionalRequestHeaderOptions":{"EnableAdditionRequestHeader":true,"RequestHeaders":[{"Key":"IP","Data":"127.0.0.1"}]}}],"GlobalConfiguration":{"RequestIdKey":"RequestId","ServiceDiscoveryProvider":{"Provider":"","Host":"","Port":0},"AdministrationPath":"/admin","IdentityServerRootUrl":"http://10.125.32.121:5000","RateLimitOptions":{"ClientIdHeader":"ClientId","QuotaExceededMessage":"","RateLimitCounterPrefix":"ocelot","DisableRateLimitHeaders":false,"HttpStatusCode":429}}}

This content should be FileConfigurationRepository written to disk AppContext.BaseDirectory is not consistent in different systems,I found in the coreclr github several issues, the state is open : https://github.com/dotnet/coreclr/issues/2128

TomPallister commented 7 years ago

@geffzhang perhaps you could write code that treats this differently when running on cent is? Previously I had code that manually worked out the base directory but it was removed because this seemed like a better solution.