Report this

What is the reason for this report?

http-https redirect / Positive SSL on nginx

Posted on October 8, 2014

Hi guys,

This is my first time here asking questions, untill now I read and learned from the best of you. So, I installed Ubuntu 14.04 on my Droplet, configured EasyEngine on it with nginx / php5-fpm and fastcgi. I bought a Positive SSL from namecheap and now I want to use it on my Wordpress site. So I put the ssl-bundle.crt and the domain_com.key in /var/www/domain.com/cert and after that I modified the file in /etc/nginx/sites-available/domain.com and put the following configuration:

# WPSINGLE FAST CGI NGINX CONFIGURATION

server {
        listen 80;
        listen 443 ssl;
        server_name devly.co www.devly.co;
        ssl on;
        ssl_certificate /var/www/devly.co/cert/ssl-bundle.crt;
        ssl_certificate_key /var/www/devly.co/cert/devly_co.key;
        access_log   /var/log/nginx/devly.co.access.log rt_cache;
        error_log    /var/log/nginx/devly.co.error.log;
        root /var/www/devly.co/htdocs;
        index index.php index.htm index.html;

        include common/wpfc.conf;
        include common/wpcommon.conf;
        include common/locations.conf;

# force https-redirects
    if ($scheme = http) {
        return 301 https://$server_name$request_uri;
}


}

The thing is, the redirect doesn’t work, if I enter http://domain.com it won’t automaticaly redirect to https. What did I do wrong ? Also any recomendations ? My first time using SSL on a server.



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!

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.

If you are using CloudFlare HTTPS

server {
   ...
   if ($**http_x_forwarded_proto** = "http") {
     return 301 https://$server_name$request_uri;
   }
   ... 
}

Peace!

hello, more one question about redirect

when put ip address for example http://ipofsitewithssl rediret to https://mysite but whe try access https://the ip address not redirect and load the site

this is my config

server { listen 80; server_name mydomain.com.br www.mydomain.com.br; return 301 https://www.mydomaincom.br$request_uri; }

server { listen 80; server_name my ip xx.xx.xx.xx; return 301 https://www.mydomain.com.br$request_uri; }

server { listen 443; server_name www.mydomain.com.br; ssl on; ssl_certificate /var/www/mydomain.com.br/cert/www_selfbox_com_br.crt; ssl_certificate_key /var/www/mydomain.com.br/cert/www_selfbox_com_br.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

This comment has been deleted

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.