Page 1 of 1

Force SSL on Vesta without Apache (nginx + php-fpm)

Posted: Tue Apr 11, 2017 7:21 pm
by Ninetou
I'm running VestaCP on nginx + php-fpm stack (no Apache) and want to force SSL connections for my domains but it doesn't seem like Vesta is prepared to handle this kind of configuration.

I tried forcing it as documented in docs http://vestacp.com/docs/#how-to-force-https but force-https template works only if you use Apache with Nginx as proxy server.
On nginx + php-fpm stack Vesta looks for php-fpm templates in

Code: Select all

/usr/local/vesta/data/templates/web/nginx/php-fpm
but there's many of them so every single one would require something like:

Code: Select all

server {
    listen      80;
    server_name mysite.com;
    return 301 https://$server_name$request_uri;
}
Is there a more centralised way of doing it?

Re: Force SSL on Vesta without Apache (nginx + php-fpm)

Posted: Tue Apr 25, 2017 11:46 am
by vikhyat
Try forcing https using php. Check this tutorial on how to force https using php https://blog.flaunt7.com/force-https-php-htaccess/

Re: Force SSL on Vesta without Apache (nginx + php-fpm)

Posted: Tue Apr 25, 2017 3:56 pm
by skurudo
Ninetou wrote:Is there a more centralised way of doing it?
templates, I think

Re: Force SSL on Vesta without Apache (nginx + php-fpm)

Posted: Fri Jan 26, 2018 6:40 pm
by cybersholt
Hello,

I was looking for the exact same thing, in the docs it is only noted for apache installs. So I duplicated the default template files, in the http template it redirects to SSL, in SSL template there is a if statement to detect the www. Simply download, extract and place the files into

Code: Select all

/usr/local/vesta/data/templates/web/nginx/php-fpm
Files are available at GitHub https://github.com/cybersholt/VestaCP-Nginx-Force-SSL

Re: Force SSL on Vesta without Apache (nginx + php-fpm)

Posted: Fri Feb 23, 2018 7:36 am
by baoang
Ninetou wrote: Tue Apr 11, 2017 7:21 pm I'm running VestaCP on nginx + php-fpm stack (no Apache) and want to force SSL connections for my domains but it doesn't seem like Vesta is prepared to handle this kind of configuration.

I tried forcing it as documented in docs http://vestacp.com/docs/#how-to-force-https but force-https template works only if you use Apache with Nginx as proxy server.
On nginx + php-fpm stack Vesta looks for php-fpm templates in

Code: Select all

/usr/local/vesta/data/templates/web/nginx/php-fpm
but there's many of them so every single one would require something like:

Code: Select all

server {
    listen      80;
    server_name mysite.com;
    return 301 https://$server_name$request_uri;
}
Is there a more centralised way of doing it?
right, I didn't see that package in the list after installing following the instructions here: https://vestacp.com/docs/#how-to-force-https

I guess putting the two files under the php-fpm may work, but it didn't.

Will VestaCP team release another detailed and updated version of instruction?

Re: Force SSL on Vesta without Apache (nginx + php-fpm)

Posted: Tue Feb 27, 2018 6:31 pm
by noogen
The goal is to have LetsEncrypt working with both force SSL when using nginx + php-fpm. You need to duplicate or modify existing template and add the force SSL instruction inside of the "location / {" default nginx directive. I've responded to another thread and created a little instruction here: viewtopic.php?f=11&t=14269#p67578

Re: Force SSL on Vesta without Apache (nginx + php-fpm)

Posted: Mon Apr 23, 2018 2:05 pm
by zaqueon
cybersholt wrote: Fri Jan 26, 2018 6:40 pm Hello,

I was looking for the exact same thing, in the docs it is only noted for apache installs. So I duplicated the default template files, in the http template it redirects to SSL, in SSL template there is a if statement to detect the www. Simply download, extract and place the files into

Code: Select all

/usr/local/vesta/data/templates/web/nginx/php-fpm
Files are available at GitHub https://github.com/cybersholt/VestaCP-Nginx-Force-SSL
It is not working for me to force without www.