Skip to content

Enable HSTS and make sure everything is HTTPS

Solved Configure
25 2 6.8k
  • @hari i’m configuring the origin server certificate hope that will not cause conflicts?

    ok, we will look it tomorrow. good night 🙂

    @hari enabling HSTS should not be this complex. I’m not sure I understand the need for the origin certificate from CF as this should still work even with a trusted and verified cert on the destination and the communication mode for SSL set to strict.

    You can actually enable HSTS and SSL stapling at server level rather than CF.

  • @hari enabling HSTS should not be this complex. I’m not sure I understand the need for the origin certificate from CF as this should still work even with a trusted and verified cert on the destination and the communication mode for SSL set to strict.

    You can actually enable HSTS and SSL stapling at server level rather than CF.

    @phenomlab Right now i am not facing any issues and everything is working perfectly

    i want to summarise all my settings

    CF settings
    SSL is set to full strict
    HSTS is enabled
    Automatic HTTPS Rewrites CF setting is ON

    disabled page rules for https redirect (earlier i used to use)


    Server-side let’s encrypt is enabled
    HTTP to HTTPS prediction is off


    i want to keep the settings like this since everything is working at the DNS level.

    if you suggest using HSTS and SSL from the server-side i will switch to it.

    the only problem with flarum www redirection

    https://domain.com/ask

    shall i define something at subdirectory ht. access for this? or something needs to be done at domain ht access?

  • @phenomlab Right now i am not facing any issues and everything is working perfectly

    i want to summarise all my settings

    CF settings
    SSL is set to full strict
    HSTS is enabled
    Automatic HTTPS Rewrites CF setting is ON

    disabled page rules for https redirect (earlier i used to use)


    Server-side let’s encrypt is enabled
    HTTP to HTTPS prediction is off


    i want to keep the settings like this since everything is working at the DNS level.

    if you suggest using HSTS and SSL from the server-side i will switch to it.

    the only problem with flarum www redirection

    https://domain.com/ask

    shall i define something at subdirectory ht. access for this? or something needs to be done at domain ht access?

    @hari said in Enable HSTS and make sure everything is HTTPS:

    shall i define something at subdirectory ht. access for this? or something needs to be done at domain ht access?

    This makes the most sense to me as the redirect can be handled at the subdirectory level. HSTS should also work at the CF level without issue. What error do you get if you enable it ?

  • @hari said in Enable HSTS and make sure everything is HTTPS:

    shall i define something at subdirectory ht. access for this? or something needs to be done at domain ht access?

    This makes the most sense to me as the redirect can be handled at the subdirectory level. HSTS should also work at the CF level without issue. What error do you get if you enable it ?

    @phenomlab No error, it just stuck without www. It should supposed to get redirected to www.domain/ask

    This only happening with flarum all other wordpress subdirectories are getting redirected without any issue.

  • @phenomlab No error, it just stuck without www. It should supposed to get redirected to www.domain/ask

    This only happening with flarum all other wordpress subdirectories are getting redirected without any issue.

    @hari Does it work if you set a redirect using rules at CF ?

  • @hari Does it work if you set a redirect using rules at CF ?

    @phenomlab Yes, if I set a page rule it used to work.

    Now shall I set a page rule for www at cloud flare (I don’t want to do it)

    I am guessing a www. Redirection at ask folder ht acess would resolve the issue.

  • @phenomlab Yes, if I set a page rule it used to work.

    Now shall I set a page rule for www at cloud flare (I don’t want to do it)

    I am guessing a www. Redirection at ask folder ht acess would resolve the issue.

    @hari said in Enable HSTS and make sure everything is HTTPS:

    I am guessing a www. Redirection at ask folder ht acess would resolve the issue.

    It should, yes. Did you create one previously, and it was ignored ?

  • @hari said in Enable HSTS and make sure everything is HTTPS:

    I am guessing a www. Redirection at ask folder ht acess would resolve the issue.

    It should, yes. Did you create one previously, and it was ignored ?

    @phenomlab No, erlier I used to manage it using CF page rule (all in one rule https and www.) . Now as we switch to HSTS and there is a setting at CF as make sure every page is https it is taking care of http to https redirection so turned of page rules.

    Could you suggest me the ht access rule for ask folder only

    I have posted my ask folder ht access in my first post of this discussion

  • @phenomlab No, erlier I used to manage it using CF page rule (all in one rule https and www.) . Now as we switch to HSTS and there is a setting at CF as make sure every page is https it is taking care of http to https redirection so turned of page rules.

    Could you suggest me the ht access rule for ask folder only

    I have posted my ask folder ht access in my first post of this discussion

    @hari So to confirm, you want all requests to this URL to be converted to https://www.domain.com ?

  • @hari So to confirm, you want all requests to this URL to be converted to https://www.domain.com ?

    @phenomlab all WordPress installations for domain or subdirectory is properly getting redirected to www. so i don’t want to add any rules in main ht access

    i want all requests to “ask” folder to be converted to www. https://www.domain.com/ask

    only flarum is not doing www. redirection

    if writing a global rule is the right approach i will try that

  • @phenomlab all WordPress installations for domain or subdirectory is properly getting redirected to www. so i don’t want to add any rules in main ht access

    i want all requests to “ask” folder to be converted to www. https://www.domain.com/ask

    only flarum is not doing www. redirection

    if writing a global rule is the right approach i will try that

    @hari You should leverage the .htaccess inside the Flarum root directory and not touch anything else. If you set the forward here, it should work as planned.

    Let me know if you need any help.

  • @hari You should leverage the .htaccess inside the Flarum root directory and not touch anything else. If you set the forward here, it should work as planned.

    Let me know if you need any help.

    @phenomlab yes i want you to suggest/modify this for me

    RewriteCond %{HTTP_HOST} ^yourdomain.com/ask [NC]
    RewriteRule ^(.*)$ http://www.yourdomain.com/ask/$1 [L,R=301]
    

    if i use this line in the subdirectory (flarum) it will redirect to to http?

    could you suggest me a line which only modify non www to www and doent touch the https or http thing since DNS is taking care of it.

  • @phenomlab yes i want you to suggest/modify this for me

    RewriteCond %{HTTP_HOST} ^yourdomain.com/ask [NC]
    RewriteRule ^(.*)$ http://www.yourdomain.com/ask/$1 [L,R=301]
    

    if i use this line in the subdirectory (flarum) it will redirect to to http?

    could you suggest me a line which only modify non www to www and doent touch the https or http thing since DNS is taking care of it.

    @hari said in Enable HSTS and make sure everything is HTTPS:

    RewriteRule ^(.*)$ http://www.yourdomain.com/ask/$1 [L,R=301]

    Before we do that, shouldn’t

    RewriteRule ^(.*)$ http://www.yourdomain.com/ask/$1 [L,R=301]
    

    Actually be

    RewriteRule ^(.*)$ https://www.yourdomain.com/ask/$1 [L,R=301]
    

    ?

  • @hari said in Enable HSTS and make sure everything is HTTPS:

    RewriteRule ^(.*)$ http://www.yourdomain.com/ask/$1 [L,R=301]

    Before we do that, shouldn’t

    RewriteRule ^(.*)$ http://www.yourdomain.com/ask/$1 [L,R=301]
    

    Actually be

    RewriteRule ^(.*)$ https://www.yourdomain.com/ask/$1 [L,R=301]
    

    ?

    @phenomlab nope it’s not working - added these lines in ask direcotry htacess

      RewriteEngine on
       RewriteCond %{HTTP_HOST} ^domain.com/ask [NC]
       RewriteRule ^(.*)$ https://www.domain.com/ask/$1 [L,R=301]
    

    tried to redirect at main folder too but its not redirecting to www for ask

    RewriteCond %{HTTP_HOST} ^domain.com/ [NC]
    RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
    

    let me try CF page rule

  • @phenomlab nope it’s not working - added these lines in ask direcotry htacess

      RewriteEngine on
       RewriteCond %{HTTP_HOST} ^domain.com/ask [NC]
       RewriteRule ^(.*)$ https://www.domain.com/ask/$1 [L,R=301]
    

    tried to redirect at main folder too but its not redirecting to www for ask

    RewriteCond %{HTTP_HOST} ^domain.com/ [NC]
    RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
    

    let me try CF page rule

    @hari CF page rule is working, i think my .htacces don’t work 😄

    496e91f4-2bb4-47a0-a946-ad9fe8dd36e8-image.png

    • Solved
  • Hariundefined Hari has marked this topic as solved on
  • phenomlabundefined phenomlab unlocked this topic on

Did this solution help you?
Did you find the suggested solution useful? Support 💗 Sudonix with a coffee
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • Nodebb to Xenforo

    Solved Configure xenforo nodebb
    3
    0 Votes
    3 Posts
    666 Views
    @cagatay as @downpw stated, there isn’t a native tool that will do this for you. You’d need to either develop your own or ask the nodebb team to assist which will be a paid exercise.
  • Spam spam spam

    Solved Configure nodebb
    6
    2 Votes
    6 Posts
    2k Views
    @Panda said in Spam spam spam: ok, yes Ive seen the queue, it shows IP, but doesnt have a field for comments from registrant. It’s not designed for that. It merely serves as a gateway between posts appearing on your form or not. @Panda said in Spam spam spam: It would be better if nodebb had this plugin included in ACP list, as not only then do you know its approved and should work, but many people cant or dont want to use CLI on the server That’s a question for the NodeBB devs but in all honesty you can’t not use the CLI when installing nodebb so to be this isn’t a big deal.
  • Nodebb and emails

    Solved Configure nodebb
    27
    5 Votes
    27 Posts
    7k Views
    @Panda it will use SMTP. In all cases, I never use any plugin to send email. I’ll always send it raw.
  • Opening links in nodebb widget

    Solved Configure nodebb
    6
    4 Votes
    6 Posts
    2k Views
    A more efficient way of including this would be to not over complicate it and leverage a standard iframe (providing the CSP headers of the remote site permit this) like below <iframe src="https://www.classmarker.com/online-test/start/?quiz=gag66aea7922f0a5" width="700" height="800"></iframe> This works first time every time on your site as intended.
  • Test of youtube embeds

    Solved Configure nodebb
    14
    11 Votes
    14 Posts
    3k Views
    @phenomlab Perfect!!! Many thanks.
  • MogoDB v6 to v7 upgrade

    Solved Configure nodebb
    5
    1 Votes
    5 Posts
    2k Views
    @Panda if you used the Ubuntu PPA, I think this only goes as far as 6.x if I recall correctly.
  • mongodb backup problem

    Moved Configure mongodb
    3
    1
    1 Votes
    3 Posts
    1k Views
    You might want to also review this post https://sudonix.org/topic/389/mongodb-backup-script
  • Email Server Settings

    Solved Configure mx entry
    25
    10 Votes
    25 Posts
    8k Views
    @Onix said in Email Server Settings: If anyone has long-term experience with self-hosted SMTP + DNS set-ups that remain stable, would be great to hear which configurations worked best. I can help with this