NGinx HTTP to HTTPs redirect for subdomain in Plesk


I ve installed Plesk on my Ubuntu 12.04 instance which runs NGinx. I am trying to redirect my subdomain calls to HTTPs. That means any call with http to my subdomain ( should redirect to (

I have followed instructions in the website but they are not working. I could not find the correct file to configure and correct configuration strings.

I am looking for your help to redirect HTTP to HTTPs. What configuration file I should work on and what configuration strings I should add?

Thanks in advance,

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Generally, you’ll want your Nginx configuration to look something like the below to redirect HTTP to HTTPs:

server {
       listen         80;
       return         301 https://$server_name$request_uri;

server {
       listen         443 ssl;

       # The rest of your normal configuration

The default configuration file is located in /etc/nginx/sites-enabled/default

We might be able to give you more specific instructions if you could give more information like what you already tried or if you can describe exactly what you mean by “not working” (i.e. was there an error message).

Cloudflare will not make your site slower, if any will be faster, specially if you use spdy, which you should as you already have nginx up and running.

Go check cloudflare’s blog, they have good explanations about the SSL and SPDY protocols they offer.

Not sure how plesk handle nginx configuration, can be messy to mess around those files too if plesk overwrites them. but you can try this and add some speed/security to your site.

Open an account at add your domain, and enable strict SSL this will route all your traffic to https even before it reaches your server, is free and add some security and speed to your site.

Now if you find the way via Plesk to avoid files being overwritten, then give it a try, but to be honest is a lot better if you avoid cpanels. One option I can think about it is to create 2 sites, one for http with a redirect (even a header redirect will work), and one for https.