ThreeMammals / Ocelot

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

Ocelot in Production Environment #80

Closed player84 closed 7 years ago

player84 commented 7 years ago

Hi, congratulations for this project!!

I did a little project with ocelot and two apis and all works fine in development, but when I publish the solution in production (with IIS) and I access to some reroute always return 404 not found. My api+ocelot has the default ValuesController (that creates Visual Studio by default) and works fine but the reroutes didn´t work in production.

It´s neccesary some special kind of configuration in the server?

Thanks.

TomPallister commented 7 years ago

@player84

Thanky you very much.

I am currently just using kestrel as the webserver without IIS. You might need to do something like this to get Ocelot working behind IIS. https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS

Hope this helps.

player84 commented 7 years ago

@TomPallister

Yes, I followed that steps (but by the microsoft web). My two Api´s are working. The problem it´s only than the reroute doesn´t work in production. I have two api:

Api1: it´s the api (in net core) that contains Ocelot (and contains also a TestController with GET method that return a string). In the configuration.json I have a reroute to redirect request to Api 2. Api2: it´s a simple api (in net core) with a TestController with GET method thant return a string.

In develop works fine but in production, Api 2 work fine while in Api1 only works the TestController and not the reroute of the configuration.json.

juancash commented 7 years ago

@player84 @TomPallister

Hi,

I had the same problem. I don´t know the reason but the IIS AppPool must have all grants over your app folder. You must go to your ocelot app folder in inetpub and add all permissions for your AppPool.

Follow the steps of this Microsoft´s tutorial: https://docs.microsoft.com/en-us/aspnet/core/publishing/iis (in section Application Pool Identity) and restart your IIS with running the command "iisreset" in the cmd like administrator. (Remember, only needed over your ocelot api folder).

It worked for me.

Hope this helps.

TomPallister commented 7 years ago

@juancash thanks for the info! Much appreciated.

player84 commented 7 years ago

@juancash @TomPallister

It works.

Thanks!!!!