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

Posted: April 19, 2017 at 4:42 AM Quote #186665
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.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: April 20, 2017 at 1:18 AM Quote #186710
Please try nopCommerce 3.90 where this issue has been fixed
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Interested in the dedicated Premium support services provided by core developers? Please visit http://www.nopcommerce.com/supportservices.aspx

Regards,
Andrei Mazulnitsyn
Posted: April 20, 2017 at 3:14 AM Quote #186713
Thanks for the reply.  I'd checked 3.8 - should have checked 3.9 too!
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2017
Learn more