Cloudflare Flexible SSL and nopCommerce problem

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 Jahre weitere
Thanks for sharing this. This is really very useful. +1
6 Jahre weitere
akrosoft wrote:
If you don't want to deal with code changes and still want free cloudflare flexible cert to work in any nopcommerce version, you can add page rules in CF to always use https and add outbound rule below:

<outboundRules>
    <rule name="Rewrite external references to use HTTPS" preCondition="IsHTML">
      <match filterByTags="Script, Link, Img, CustomTags" customTags="HTML5Tags" pattern="^http://(.*)$" />
      <action type="Rewrite" value="https://{R:1}" />
    </rule>
    <preConditions>
      <preCondition name="IsHTML">
        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
      </preCondition>
    </preConditions>
    <customTags>
      <tags name="HTML5Tags">
        <tag name="Video" attribute="src" />
      </tags>
    </customTags>
  </outboundRules>

This will work without check in store configuration to useSSL and without forceSSL setting.


you are a superstar! although I would change your comment to say:

create the "always use https" page rule in cloudflare and add the following to your existing web.config file in the <system.webServer> section, for example:


<system.webServer>

...

    <rewrite>
      <outboundRules rewriteBeforeCache="true">
    <rule name="Rewrite external references to use HTTPS" preCondition="IsHTML">
      <match filterByTags="Script, Link, Img, CustomTags" customTags="HTML5Tags" pattern="^http://(.*)$" />
      <action type="Rewrite" value="https://{R:1}" />
    </rule>
    <preConditions>
      <preCondition name="IsHTML">
        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
      </preCondition>
    </preConditions>
    <customTags>
      <tags name="HTML5Tags">
        <tag name="Video" attribute="src" />
      </tags>
    </customTags>
  </outboundRules>
    </rewrite>
  </system.webServer>
6 Jahre weitere
Actually, the above doesn't work properly... It screws up the one page checkout and when continuing from entering the billing address, takes you back to the checkout page :-(
4 Jahre weitere
networkfusion wrote:
Actually, the above doesn't work properly... It screws up the one page checkout and when continuing from entering the billing address, takes you back to the checkout page :-(


Found a workaround for this, just need to change the ~\Theme\Views\Checkout\OnePageCheckout.cshtml
Change (nopcommerce 4.x):
var storeLocation = webHelper.GetStoreLocation();
to:
var storeLocation = webHelper.GetStoreLocation(true);
4 Jahre weitere
For those who are still struggling with Cloudflare Flexible SSL, this is how we solved the issue in nop 4.20:
1. Set UseHttpXForwardedProto = true in Nop.Web/appsettings.json (Cloudflare setups X-Forwarded-Proto header to determine if request is secured. See more https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers- ).
2. Ensure "Always Use HTTPS" setting is enabled in Cloudflare.
3. Ensure nopCommerce Store "URL" has https schema.
4. Ensure nopCommerce Store "SSL Enabled" setting is set to true.
5. Ensure nopCommerce "Force SSL for all pages" is enabled.
4 Jahre weitere
Thanks ellasoftware,
I can confirm it works with nopCommerce 3.9 too. Need to enable (Web.config):
<add key="Use_HTTP_X_FORWARDED_PROTO" value="true" />
4 Jahre weitere
mchen8 wrote:
Actually, the above doesn't work properly... It screws up the one page checkout and when continuing from entering the billing address, takes you back to the checkout page :-(

Found a workaround for this, just need to change the ~\Theme\Views\Checkout\OnePageCheckout.cshtml
Change (nopcommerce 4.x):
var storeLocation = webHelper.GetStoreLocation();
to:
var storeLocation = webHelper.GetStoreLocation(true);


I am unable to find this in nopCommerce 4.20 - Can I find it somewhere else?
4 Jahre weitere
ellasoftware wrote:
For those who are still struggling with Cloudflare Flexible SSL, this is how we solved the issue in nop 4.20:
1. Set UseHttpXForwardedProto = true in Nop.Web/appsettings.json (Cloudflare setups X-Forwarded-Proto header to determine if request is secured. See more https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers- ).
2. Ensure "Always Use HTTPS" setting is enabled in Cloudflare.
3. Ensure nopCommerce Store "URL" has https schema.
4. Ensure nopCommerce Store "SSL Enabled" setting is set to true.
5. Ensure nopCommerce "Force SSL for all pages" is enabled.


Hi,

This doesn't seem to work for me.. I'm using nopCommerce 4.20 and I followed all of these steps but end up having a redirect loop as soon as I check the "SSL Enabled" box.

Do you have any suggestions?
4 Jahre weitere
I am still looking for ways to resolve it, is there any configuration for Nginx SSL?
3 Jahre weitere
ellasoftware wrote:
For those who are still struggling with Cloudflare Flexible SSL, this is how we solved the issue in nop 4.20:
1. Set UseHttpXForwardedProto = true in Nop.Web/appsettings.json (Cloudflare setups X-Forwarded-Proto header to determine if request is secured. See more https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers- ).
2. Ensure "Always Use HTTPS" setting is enabled in Cloudflare.
3. Ensure nopCommerce Store "URL" has https schema.
4. Ensure nopCommerce Store "SSL Enabled" setting is set to true.
5. Ensure nopCommerce "Force SSL for all pages" is enabled.


Thank you so much.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.