.net core Razor callback from Discord behind reverse Proxy
Hey Everyone,
i am not sure if you can help me here.
I Build an Razor Pages application which works fine on my PC, the Callback from oauth Discord worrks fine.
Now i am trying to Publish it on an IIS behhind an Reverse Proxy.
The Site at it self works fine, but the Discord Login didnt work.
The Server is running under 192.168.2.20 and the reverse Proxy is rewriting the Url and Headers.
Right now when i am at the Point with the url callback from Discord i getting an error.
I tried to publish with debug settings butt he Error Page is the same.
Does someone have an idea or an tipp how can i enable the Development mode on iis?
Thanks
24 Replies
it says so in the error message: set the environment variable "ASPNETCORE_ENVIRONMENT" to Development
an other thing you might want to consider is getting your logging setup. this will benefit you in the long run, too (when other errors happen) 😉
yeah but whhere can i set the variables? 😉
What do you mean with the logging setup?
you should be able to set environment variables per app pool in iis: https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/environmentvariables/
Environment Variables
Overview The element of the / element specifies a list of environment variables that Intern...
if you setup logging, you can check the logs to see what error occurred, instead of having to enable development mode, to see the error when you call the webpage
oaky thanks, i will check the logging maybe i need to edit the logging 😉
@icebear
i am not sure if it could be that this is the problem
Log:
GET /auth/oauthCallback code=cBcS
Browser:
/auth/oauthCallback?code=
in the log file the ? is missing
okay i found the settings, now i need to check hats wrong here...
that looks like the iis request log
i think that's the normal format for it (without the "?")
i was mostly talking about logging within your app (with "Microsoft.Extensions.Logging" for example)
not sure about the error tbh ... maybe check samesite settings
Do you get 502 error on post?
@Heartbeat
no its an 500.
I think its the case of rewriting thhe urrl
i am not sure if i can change the callback URL, but also trying to change the internal to https.
in the package i have only the possibilities to set the callback string
Aha okay I was just wondering because just yesterday I had similar problem where in development it was working fine but after putting it in production behind nginx reverse proxy I was getting same error and it ended up being problem that header was too big beacuse of auth cookies
Yes for sure you need to use https
Did you forward protocol from header?
Configure ASP.NET Core to work with proxy servers and load balancers
Learn about configuration for apps hosted behind proxy servers and load balancers, which often obscure important request information.
Beacaue in reverse proxy if you have ssl offloading
yeah forwarded everything, i am not sure if i can get it wworking internally with https 😉
You have to do this
okay i will check the link
app.Use((context, next) =>
{
context.Request.Scheme = "https";
return next(context);
});
i thinkk this will help me
One way to do it, not best way but for testing purposes
yeah need to check and then try to rebuild it internally to https. Not sure if i can get it worrking .... 😉
I use this for header forwarding
okay thanks
Np, hope i can help
yeah the setting with context.Request.Scheme = "https"; worrked... 😉
for the moment i thhink i will leave it like that but try to change it to internal hhttps
thanks for the hints