nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.07k stars 5.19k forks source link

Default value for appsettings.josn 'ForwardedProtoHeaderName' #6238

Closed jakubmaguza closed 2 years ago

jakubmaguza commented 2 years ago

Hello, I belive ForwardedProtoHeaderName should be set to null or X-Forwarded-Proto Setting it to empty string is confusing and creating a problem from this topic: https://www.nopcommerce.com/en/boards/topic/89707/problem-with-ssl

It was easier to set it up with previous appsetting.json version, because it was true or false. This is now string property and if we want to use default option we should set it to null.

ekjuanrejon commented 2 years ago

in my opinion all those infrastructure settings should be transparent to the application. The application should be able to handle it. whether it is behind a load balancer or not. should be agnostic whether it runs in docker, vm, azure appservice, k8s, azure container apps or any other cloud infrasturcture

exileDev commented 2 years ago

This property will set the header used to retrieve the value for the originating scheme (HTTP/HTTPS) If a proxy uses a different one. And we check it with string.IsNullOrEmpty before use, so I don't think it matters. Now the UseProxy property has almost the same behaviour.

Closed #6238

jakubmaguza commented 1 year ago

Yes, you are checking it with string.IsNullOrEmpty, but it defaults to empty string. The problem is that empty string and null for this property are totally different values.

So if you will use nginx as reverse proxy and enable ssl in config, you will not be able to access website, there will be a loop of redriects. Setting this to null or X-Forwarded-Proto will fix that.

I'm writing this for future reference. I had exactly the same problem few months later.

jakubmaguza commented 1 year ago

Another thread with the same issue: https://www.nopcommerce.com/en/boards/topic/94036/ssl-enabled-causes-infinite-301/page/2

chashik commented 1 year ago

Another thread with the same issue: https://www.nopcommerce.com/en/boards/topic/94036/ssl-enabled-causes-infinite-301/page/2

I believe that this thread emphasizes setting "UseProxy" to "true". That resolves the problem with reverse proxies for the most of cases even if the other Hosting Options remain default.

I still a bit confused why dotnet doesn't listen to 5001 for https. But it is not important.