I’m trying to setup a web server using Apache as reverse proxy connected to a ASP.NET CORE web application hosted by kestrel. I’ve followed the tutorial here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
The website uses the Google Calendar Api to get a users calanedar information. This works fine when I host it with Kestrel through Visual Studio. However, when I try to authenticate and select a Google Account through the web server, I get redirected to
127.0.0.1:5000/signin-oidc
which is not the desired result. (127.0.0.1:5000 is configured as the ProxyPass and ProxyReverse for Apache).
Since the web application works when I run without the Apache reverse proxy, I suspect there is some issues with the apache configuration. However, it might as well be a problem with the Google.Apis.Auth.AspNetCore3 library I am using. I’ve used the the integrationtests as a guide on how to setup startup.cs and how to make the Api requests.
Edit:
So I asked the developers of the library that I’m using. The redirect uri is bound to the endpoint that kestrel I listening on. The question is here: https://github.com/googleapis/google-api-dotnet-client/issues/1680
So it can only work if I can somehow get kestrel to know the “actual” domain name or public IP of my server… From my research, this seems near if not impossible. I will be looking into other implementation options for authorization and authentication.
3
Answers
A solution was found!
In my endless seach and noobiness I've found out that I've deleted the forward header for my VirtualHost for apache. I've also added the ProxyPreserveHost option.
I changed the virtual host to include
Adding above two Directives does the job
References:
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto https
if you are using net core, adding the right configuration to virtual host is not enough, you need to add
and