Page 1 of 2

How to force SSL for one domain?

Posted: Tue Apr 14, 2015 8:47 pm
by mark
How to force SSL for one domain?

Re: How to force SSL for one domain?

Posted: Wed Apr 15, 2015 8:00 am
by skurudo
There is two ways:
1 - templates - need to change - https://vestacp.com/docs/#how-to-force-https
or
2 - some change in domain nginx conf file

Re: How to force SSL for one domain?

Posted: Wed Apr 15, 2015 8:01 pm
by mark
Thanks. This worked perfectly.

What code of line should I add to the template to make all www-requests redirect to non-www as well?

Re: How to force SSL for one domain?

Posted: Wed Apr 15, 2015 8:15 pm
by skurudo
mark wrote:What code of line should I add to the template to make all www-requests redirect to non-www as well?
There is simple way:

Code: Select all

      if ($http_host != "www.domain.ru") {
                 rewrite ^ http://domain.ru$request_uri permanent;
       }

Re: How to force SSL for one domain?

Posted: Thu Apr 16, 2015 3:26 am
by DFS
using if - bad way

use

Code: Select all

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

server {
    listen       80;
    server_name  www.example.com;
    ...
}
if using SSL

Code: Select all

server {
    listen 80;
    listen 443 ssl;
    server_name www.example.com;
    return 301 $scheme://example.com$request_uri;
}

server {
    listen 80;
    listen 443 ssl;
    server_name example.com;
    # rest goes here...
}

Re: How to force SSL for one domain?

Posted: Thu Apr 16, 2015 5:14 am
by skurudo
DFS wrote:using if - bad way
Omg ) I was too sleepy to write about second way.
Yep, I know about "IF is Evil" - http://wiki.nginx.org/IfIsEvil
But in non-highload projects with configs less than 1k domains it's faster/simple and secure to use.

Thanks DFS, need to tell about ideologically correct things too )

Re: How to force SSL for one domain?

Posted: Sat Apr 18, 2015 11:05 am
by webass
Hi,
I am having huge issues to run SSL.

I just have a WEB in vestacp.
In the public_html folder I run a wordpress secured with BulletProof Security. I get some hints from there also, thexy say I must add this code to the .htaccess.

Code: Select all

 # WP REWRITE LOOP START
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} ^80
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule ^index\.php$ - [L] 
So, in that public_html folder also a WHMCS instlalation runs which I later want to have SSL running on too. In this it doesnt work also.
I always get "Page is unavailable":

I thought that I just take the SSL cert from my provider (I have them create all necessary files)
then add it it to the correct boxes in vestacp, there I get a green "changes are saved" and fine.
But because both systems are not working to use SSL, wordpress and WHMCS, I either cannot test anything with sslshopper also and I am really concerned about why it is not working...
Do I have to make it like in the link shown above https://vestacp.com/docs/#how-to-force-https ? never worked with nginx...
Please anybody help soon.
My nerves...

Cheers.
Andre


EDIT: HAHAHA, that was it...
I just followed the instructions and on the WEB I changed the Ngnx template to the new one.. Then it works...

Re: How to force SSL for one domain?

Posted: Mon Apr 20, 2015 2:46 pm
by skurudo
webass wrote:EDIT: HAHAHA, that was it...I just followed the instructions and on the WEB I changed the Ngnx template to the new one.. Then it works...
Well done, man! ^_^

Re: How to force SSL for one domain?

Posted: Thu Nov 05, 2015 6:21 am
by linboxs
Hi skurudo,

My website is bitpow.co and i've an issue on my VestaCP about force ssl.

I've follow instruction from this link: https://vestacp.com/docs/#how-to-force-https, i've change the proxy template to force-https but the web just loading and then shown this: The page isn't redirecting properly

Error log shown nothing. What should the configuration must be checking?

Thanks

Re: How to force SSL for one domain?

Posted: Thu Nov 05, 2015 9:59 am
by skurudo
linboxs wrote: I've follow instruction from this link: https://vestacp.com/docs/#how-to-force-https, i've change the proxy template to force-https but the web just loading and then shown this: The page isn't redirecting properly
You use some tricky htaccess or php with routing?