Search code examples
dockeridentityserver4

IdentityServer4 with multiple instances


I have two docker containers with the same image of our OAuth Server with IdentityServer4 managed with Docker Swarm (I don't take care of this).

The problem is that the token sometimes is valid and sometimes not when it's valid (401 Unauthorized).

We tried leaving only one instance running and the problem was solved, but we need two.

How can I configure multiple instances of the server?

Notes:

  • We are using the AddDeveloperSigningCredential(). I don't know if it will affect or not.
  • It's a test environment with ASPNETCORE_ENVIRONMENT=Development

Solution

  • The problem was that the tempkey.rsa file was different in both instances of the IdentityServer.

    I had to configure the file with the build action to "copy always" to be included in the built project and therefore in the docker image.

    I know that in production it should not be used in this way, but it was an urgent need for a demo.