• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

How to redirect http to https?

Manuel_Caramia

Regular Pleskian
Hi,
I have bought ssl certificate but if I open my site I think it is redirect to http because I dont see https. I use nginx like web server. Anyone can help me to redirect please? Tjanks
 
Hi Manuel_Caramia,

you have the choice to add additional webserver - settings directly over the Plesk - Control - Panel at: Websites & Domains > YOUR_DOMAIN.COM > Web Server Settings

For apache you could use:
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

For nginx you could use:
Code:
if ($scheme !~* ^https ){
rewrite ^ https://$server_name$request_uri? permanent;
}
 
Hi Manuel_Caramia,

you have the choice to add additional webserver - settings directly over the Plesk - Control - Panel at: Websites & Domains > YOUR_DOMAIN.COM > Web Server Settings

For apache you could use:
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

For nginx you could use:
Code:
if ($scheme !~* ^https ){
rewrite ^ https://$server_name$request_uri? permanent;
}
Hi, I have tried both settings but I receive this error:
ERR_TOO_MANY_REDIRECTS
I have error of loop.
How is it possible?
 
Hi

please redo your changes over the Plesk - Control - Panel for your nginx directive and save the settinsg without any additional nginx directives.

Afterwards, please make a copy of your current "nginx.conf" ( or "last_ip_default.conf", if this is the standard domain for your defined IP ) with the command:

mv /var/www/vhosts/system/YOUR_DOMAIN.COM/conf/nginx.conf /var/www/vhosts/system/YOUR_DOMAIN.COM/conf/nginx.conf.saved_for_backup


To continue, open the file /var/www/vhosts/system/YOUR_DOMAIN.COM/conf/nginx.conf and add the following lines after each of these definition:

error_log "/var/www/vhosts/system/YOUR_DOMAIN.COM/logs/proxy_error_log";

Code:
    if ($host ~* ^YOUR_DOMAIN.COM$) {
        rewrite ^(.*)$ https://YOUR_DOMAIN.COM.de$1 permanent;
    }

Save your edits and reload/restart nginx, please. Report any issues, please.
 
Hi

please redo your changes over the Plesk - Control - Panel for your nginx directive and save the settinsg without any additional nginx directives.

Afterwards, please make a copy of your current "nginx.conf" ( or "last_ip_default.conf", if this is the standard domain for your defined IP ) with the command:

mv /var/www/vhosts/system/YOUR_DOMAIN.COM/conf/nginx.conf /var/www/vhosts/system/YOUR_DOMAIN.COM/conf/nginx.conf.saved_for_backup


To continue, open the file /var/www/vhosts/system/YOUR_DOMAIN.COM/conf/nginx.conf and add the following lines after each of these definition:

error_log "/var/www/vhosts/system/YOUR_DOMAIN.COM/logs/proxy_error_log";

Code:
    if ($host ~* ^YOUR_DOMAIN.COM$) {
        rewrite ^(.*)$ https://YOUR_DOMAIN.COM.de$1 permanent;
    }

Save your edits and reload/restart nginx, please. Report any issues, please.
Hi, I have tried to add that lines after: error_log "/var etc" but with no success.
This is what I added:
if ($host ~* ^orderhosting.it$) {
rewrite ^(.*)$ https://orderhosting.it.de$1 permanent;
}
Thank you
 
Hi Manuel_Caramia,

for further investinations, please post your current "nginx.conf" ( or "last_ip_default.conf", if this is the standard domain for your defined IP ).
 
Code:
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

server {
    listen 192.99.36.73:443 ssl;

    server_name orderhosting.it;
    server_name www.orderhosting.it;
    server_name ipv4.orderhosting.it;

    ssl_certificate             /usr/local/psa/var/certificates/cert-uel1tV;
    ssl_certificate_key         /usr/local/psa/var/certificates/cert-uel1tV;
    ssl_client_certificate      /usr/local/psa/var/certificates/cert-zOr8vS;
    ssl_session_timeout         5m;

    ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers                 HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    client_max_body_size 128m;

    root "/var/www/vhosts/orderhosting.it/httpdocs";
    access_log "/var/www/vhosts/system/orderhosting.it/logs/proxy_access_ssl_log";
    error_log "/var/www/vhosts/system/orderhosting.it/logs/proxy_error_log";

    if ($host ~* ^orderhosting.it$) {
        rewrite ^(.*)$ https://www.orderhosting.it$1 permanent;
    }

    location / {
        proxy_pass https://192.99.36.73:7081;
        proxy_set_header Host             $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Accel-Internal /internal-nginx-static-location;
        access_log off;
    }
  location /internal-nginx-static-location/ {
        alias /var/www/vhosts/orderhosting.it/httpdocs/;
        add_header X-Powered-By PleskLin;
        internal;
    }

    include "/var/www/vhosts/system/orderhosting.it/conf/vhost_nginx.conf";
}

server {
    listen 192.99.36.73:80;

    server_name orderhosting.it;
    server_name www.orderhosting.it;
    server_name ipv4.orderhosting.it;

    client_max_body_size 128m;
  root "/var/www/vhosts/orderhosting.it/httpdocs";
    access_log "/var/www/vhosts/system/orderhosting.it/logs/proxy_access_log";
    error_log "/var/www/vhosts/system/orderhosting.it/logs/proxy_error_log";

    if ($host ~* ^orderhosting.it$) {
        rewrite ^(.*)$ http://www.orderhosting.it$1 permanent;
    }

    location / {
        proxy_pass http://192.99.36.73:7080;
        proxy_set_header Host             $host;
        proxy_set_header X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Accel-Internal /internal-nginx-static-location;
        access_log off;
    }

    location /internal-nginx-static-location/ {
add_header X-Powered-By PleskLin;
        internal;
    }

    include "/var/www/vhosts/system/orderhosting.it/conf/vhost_nginx.conf";
}
Hi Manuel_Caramia,

for further investinations, please post your current "nginx.conf" ( or "last_ip_default.conf", if this is the standard domain for your defined IP ).
 
Hi Manuel_Caramia,

did you notice, that you defined for port 80 only http instead of the rewrite to https ?

if ($host ~* ^orderhosting.it$) {
rewrite ^(.*)$ http://www.orderhosting.it$1 permanent;
}

Please be aware, that if you would like to have a rewrite to HTTPS, it is necessary, that you use the rewrite rule as well for port 80 and not only for port 443.

Please be sure to reload/restart your nginx as well, after your changes, because otherwise your changes never will be set, due to the case, that nginx didn't reload the configuration files. At the moment, your redirection in your configuration is defined as followed:

If any of the files for "orderhosting.it/*" is requested by a browser, then SSL should be redirected to "https://www.orderhosting.it", but afterwards you define for port 80, that all requested content should be redirected to "http://www.orderhosting.it" ( as you can see... NO https, so NO SSL! ).

=> http://showredirects.com/?url=http://orderhosting.it
 
Hi Manuel_Caramia,

did you notice, that you defined for port 80 only http instead of the rewrite to https ?



Please be aware, that if you would like to have a rewrite to HTTPS, it is necessary, that you use the rewrite rule as well for port 80 and not only for port 443.

Please be sure to reload/restart your nginx as well, after your changes, because otherwise your changes never will be set, due to the case, that nginx didn't reload the configuration files. At the moment, your redirection in your configuration is defined as followed:

If any of the files for "orderhosting.it/*" is requested by a browser, then SSL should be redirected to "https://www.orderhosting.it", but afterwards you define for port 80, that all requested content should be redirected to "http://www.orderhosting.it" ( as you can see... NO https, so NO SSL! ).

=> http://showredirects.com/?url=http://orderhosting.it
Hi, I have pasted it without your configuration only to controll the correct configuration of nginx.conf.
Now in nginx.conf I added this strings:
if ($host ~* ^orderhosting.it$) {
rewrite ^(.*)$ https://orderhosting.it.de$1 permanent;
}
As you said and after error_log "/var/www/vhosts/system/YOUR_DOMAIN.COM/logs/proxy_error_log";
I have reloaded nginx but with no success.
Thank you.
 
Hi Manuel_Caramia,

sorry... but the suggestion is absolutely correct and will work, if you put the mentioned lines directly into "nginx.conf" ( or "last_ip_default.conf", if this is the standard domain for your defined IP ). Please contact your server administrator, or consider opening a support - ticket ( Parallels - Support ).
 
Back
Top