US Culture on Admin panel is not set when using a proxy with SSL Enabled

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Setup:

Nop version: 3.7
Nginx Proxy (any other proxy would do)
Webconfig:
+ Set to use http_x_forwarded_proto  ie
<add key="Use_HTTP_X_FORWARDED_PROTO" value="true" />

Store settings:  
+ Url:  http://www.yourdomain.co.uk/
+ SSL Enabled
+ SSL url - not set

With this setup the culture on the Admin panel is not set to US - so the Telerik controls where dates are involved will fail validation.

Cause:
The Global.ascx function SetWorkingCulture (line 185) compares the current page url with the storelocation (see line 201).  The issues lies in webHelper.GetThisPageUrl(false)

WebHelper - line 188

        public virtual string GetThisPageUrl(bool includeQueryString, bool useSsl)
        {
            string url = string.Empty;
            if (!IsRequestAvailable(_httpContext))
                return url;

            if (includeQueryString)
            {
                string storeHost = GetStoreHost(useSsl);
                if (storeHost.EndsWith("/"))
                    storeHost = storeHost.Substring(0, storeHost.Length - 1);
                url = storeHost + _httpContext.Request.RawUrl;
            }
            else
            {
                if (_httpContext.Request.Url != null)
                {
                    url = _httpContext.Request.Url.GetLeftPart(UriPartial.Path);
                }
            }
            url = url.ToLowerInvariant();
            return url;
        }


You can see above - if includeQueryString is true it returns the url based on the useSsl param.  The useSsl param is set from webHelper.IsCurrentConnectionSecured - and this takes into account if the http header x-forwarded-for is set.  

If includeQueryString is false however then it just gets the current context url - which behind the proxy is http, but if useSsl is true (which it is because of the x-forwarded-for header) then the url returned should be https.

Because it returns a http url - it compares this with getStoreLocation (which correctly returns the url as https) in Global.ascx, line 201  and therefore the compare fails - so the SetTelerikCulture is not called.
7 years ago
Please try nopCommerce 3.90 where this issue has been fixed
7 years ago
Thanks for the reply.  I'd checked 3.8 - should have checked 3.9 too!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.