Cannot redirect to authorize page when fusionauth and front end app dockerized
-
I have run into an issue which I am not sure how to solve.
Following the .NET sample application, the docker-compose file is containerising the fusionauth instance and the database, while the .NET application is not dockerized.
The appsettings.json sets the Authority to http://localhost:9011 and all works fine.
But if you dockerize the .NET application as well, and include it in the same docker-compose file then there will be an issue with the login and logout functionality, because the Authority http://localhost:9011 will not be accessible.
This is understandable because to let your containers speak to each other you need to use the container name set in the dockercompose. So if I change the Authority to http://fusionauth:9011 (my FusionAuth service in the dockercompose is named fusionauth), then when clicking login on the app you will see this.
So it cannot resolve the path for some reason. The odd thing is by manually updating the url from that image above to the below, it will work.
But this only works when inputting the localhost manually and not when setting the Authority in the appsettings.json.
-
@ronn316 said in Cannot redirect to authorize page when fusionauth and front end app dockerized:
But if you dockerize the .NET application as well
Do you mean run the .Net application in the same docker image as the FusionAuth applicaiton? If so, the application was not designed to run in this configuration. That is not to say it is not possible, it will likely just take a little extra configuration.
-
@mark-robustelli not exactly, it's dockerized but in its own container. So fusionauth is running in one container and the .Net app in another. They're both in the same docker-compose though.
-
@ronn316 Ok. That makes sense. So we can have a baseline, can you get the application to run as designed? Meaning running the code on the local machine and having the FusionAuth application run in docker?
-
@mark-robustelli yes it works just fine this way.
-
@ronn316 Ok, so this looks like an issue with the "dockerized" .Net app not being able to see the "dockerized" FusionAuth app. It sounds like a configuration issue with docker. If you ping the fusionauth url from the .Net app container, it will likely returned not found. You will need to figure out how to get that to resolve to the IP of the FusionAuth app container. Once you figure that out, I would think it would work. Unfortunately, I'm not familiar enough with docker network to figure that out. Hopefully, someone else can chime in.
-
@mark-robustelli I came across a solution online. Changing the Authority in the webapp appsettings to the local machine IP address seemed to fix it.
"Authority": "http://10.1.20.69:9011",
I'm not sure I like this approach because my local IP probably isn't static. I would much rather localhost:9011 or fusionauth:9011 to work, but I don't understand networking enough to understand why they don't.
Anyway this issue will only be occurring in development so I can deal with it. In production each app will be hosted separately so using the public domain name as the authority should work.
-
@ronn316 Awesome glad to see you got it working. I'm sure there is a way to use a dns name, but like I mentioned before, someone with a little more docker experience would have to help us out here. Thanks for working this through and sharing with the community.
-