Bobcares

The right way to set Webmin redirect from http to https

by | May 7, 2019

SSL certificate on the website allows visitors to securely access.

In other words, by typing domain.com in a web-browser, a user should redirect to https://domain.com securely.

For this, there is an advanced feature in Webmin to redirect HTTP to HTTPS by default.

At Bobcares, we often get requests from our customers to set up “Webmin redirect HTTP to HTTPS” as part of our Server Management Services.

Today, we’ll see how our Support Engineers configure redirection in Webmin and fix the top 2 common issues.

 

How we redirect HTTP to HTTPS in Webmin

To redirect the non-SSL site to SSL site becomes quite easy with the advanced feature in Webmin control panel.

Let’s take a closer look at how we configure redirection to HTTPS in Webmin.

1. First, we logged into Webmin panel.

2. Next, go to Webmin > Webmin Configuration > SSL Encryption .

3. Then, selected Redirect non-SSL requests to SSL mode? to Yes.

4. After that, we go to Virtualmin > System Settings > Virtualmin Configuration.

5. And in the SSL settings column, we selected Yes on the Redirect HTTP to HTTPS by default?.

6. Finally, saved the file.

Now, the users could automatically access the URL without typing http or https in front of the URL.

 

The top 2 common problems after setting redirection to HTTPS in Webmin

Even after setting HTTPS redirection properly, we often see errors.

Let’s see the top 2 common errors and how our Support Engineers fixed it.

 

1. Incorrect .htaccess rule in Apache

Recently, one of our customers reported that after setting the redirection and when he tried to access the Webmin URL, it doesn’t seem to work properly. Also, he mentioned that he was using the Apache web server.

So, to fix the problem we took the following steps.

1. First, we logged into Webmin.

2. And we navigated to Virtualmin section.

3. Then we located Configure Websites under Services.

4. Next, we clicked Edit Directives and looked for RewriteEngine On.

5. Then under RewriteEngine On we pasted the rule like

RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [R]

6. Finally, we restarted apache to save the changes made.

/etc/init.d/apache2 restart

Now, the user could automatically access the URL without any failure.

 

2. Bad settings in Nginx configuration file

Likewise, another customer approached us with the problem after redirection in Webmin has set and when he tried to access the URL it resulted in an error like this

This error normally arises when you do not properly configure Nginx settings to handle both HTTP and HTTPS requests.

So, to solve this error we performed the following steps.

1. First, we opened the Nginx configuration file in vi editor.

vi /etc/nginx/conf.d/default.conf

2. And then we added the following line of codes to the file.

server {
listen 80;
server_name  www.example.com x.x.x.x;
return 301 https://$server_name$request_uri;}

3. Finally, we restarted the Nginx service.

systemctl restart nginx

Now, the user could access Webmin and he no more gets an error like “400 Bad Request: The plain HTTP request was sent to HTTPS port”.

That’s how we fixed the problem.

[Having trouble with Webmin redirect HTTP to HTTPS? We’ll fix it for you.]

 

Conclusion

To be more precise, for secure websites there is an advanced feature in Webmin to redirect HTTP to HTTPS by default. Today, we saw the top 2 common issues related to Webmin redirection and how our Support Engineers fixed them.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

5 Comments

  1. Dominic Desbiens

    Hi,

    Thanks for this nice post, it fixed all the questions and the bug i had (adding the line in htaccess).

    Reply
  2. Geoff

    I adjusted the settings as suggested but it only worked in part. Calling the http domain took to the https version but declared it was not secure and showed no padlock. Clicking any link on the site home page then opened a page which generated the padlock icon correctly.

    So I added the rewrite rule (nervously) and rebooted the apache server and I am pleased to say it works fine now. Thanks for the guidance.

    Reply
  3. Cartes

    Thank you for the well written article! However, I’m surprised that the Webmin / Virtualmin configuration directives already do not take care of this issue. Is this supposed to be a bug? Or is it a how they’re supposed to work?

    Reply
  4. Mutawe

    Thank you for this great article, I saved my virtual server because my service provider is not giving any help with virtual servers and it has left me with this stuck in the mud

    Reply
    • Hiba Razak

      Hi,
      Glad to know that our article helps you solves the issue ? .

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF