Page 1 of 1

Force-HTTPS template isn't working on NGINX+PHP-FPM setup

Posted: Sat Jan 07, 2017 2:16 pm
by AnimusAstralis
Hello,

I made a clean custom install (NGINX+PHP-FPM) on a fresh droplet.

According to the instructions force-https template should be extracted to

Code: Select all

/usr/local/vesta/data/templates/web/nginx/
So I did it like I had done it before on default installations (and it worked). In this case I can't choose this template from dropdown menu because nginx templates are now located in:

Code: Select all

/usr/local/vesta/data/templates/web/nginx/php-fpm/
Simply moving template there doesn't work and moreover, nginx fails to restart after choosing this template.

I'm lost here (I'm neither total noob nor specialist). Either I need another template or maybe some proper instructions for installing force-https template on NGINX+PHP-FPM configuration.

I would be grateful for any help!

Re: Force-HTTPS template isn't working on NGINX+PHP-FPM setup

Posted: Wed Jan 18, 2017 10:36 am
by gcwilliams
Were you ever able to figure this out? I'm trying to do the same thing, but no luck so far. Thanks.

Re: Force-HTTPS template isn't working on NGINX+PHP-FPM setup

Posted: Sat Jan 21, 2017 2:22 am
by noogen
try:

Code: Select all

nginx -t
What does it say? If you still can't figure out from error, can you post your conf files?
/home/*/conf/web/nginx.conf
/home/*/conf/web/snginx.conf
/home/*/conf/web/nginx.*.conf_letsencrypt

Re: Force-HTTPS template isn't working on NGINX+PHP-FPM setup

Posted: Sat Mar 11, 2017 11:45 am
by wjp
Hello
I have something to report concerning the issue raised by the op. in this post and finally I have a question.

I installed VestaCP a couple of days ago. My install uses nginx + php-fpm (no apache). Everything has been going fine except for trying to force sites to use https. In searching for answers I have found this current post. I found the same as the op. in that my installation looks in /usr/local/vesta/data/templates/web/nginx/php-fpm for templates. But having done a little digging I have something to add. Moving the two force-ssl templates to the php-fpm sub-folder location does work, in that the force-https option is now available to select in the control panel dropdown control. However, having selected the force-https option and updated the nginx config, nginx will not restart. Upon investigation, this is because (1) force-https.tpl contains a reference to a placeholder named proxy_port, and (2) force-https.stpl contains a reference to a place holder named proxy_ssl_port. Neither of these two place holders is referenced in my /usr/local/vesta/conf/vesta.conf, which contains these values:

Code: Select all

WEB_SYSTEM='nginx'
WEB_PORT='80'
WEB_SSL_PORT='443'
WEB_SSL='openssl'
WEB_BACKEND='php-fpm'
STATS_SYSTEM='webalizer,awstats'
MAIL_SYSTEM='exim4'
ANTIVIRUS_SYSTEM='clamav-daemon'
ANTISPAM_SYSTEM='spamassassin'
IMAP_SYSTEM='dovecot'
CRON_SYSTEM='cron'
FIREWALL_SYSTEM='iptables'
BACKUP_SYSTEM='local'
LANGUAGE='en'
VERSION='0.9.8'
DB_SYSTEM='mysql'
Consequently, when /home/admin/conf/web/nginx.conf and /home/admin/conf/web/nginx.conf are updated to reflect the changes, they contain lines like this:

Code: Select all

listen      111.222.333.444:;
Notice the missing port number, which causes nginx to be unable to restart successfully.

My immediate question is what should the values be for the two proxy placeholders? I don't properly understand how that is supposed to work. I can update the appropriate locations myself if know what values to use until such time as this is fixed properly by the developers.

Thanks for your help and for such a good open-source project.

Re: Force-HTTPS template isn't working on NGINX+PHP-FPM setup

Posted: Mon Mar 13, 2017 2:15 pm
by SS88
If you still cannot get the template to work, here is another solution:

Create a new file like so:

Code: Select all

/home/USER/conf/web/nginx.vestacp.com.conf
Add this code in:

Code: Select all

if ($scheme = http) { return 301 https://vestacp.com$request_uri; }
Where USER and vestacp.com are - replace with real username and domain name.

Re: Force-HTTPS template isn't working on NGINX+PHP-FPM setup

Posted: Tue Mar 14, 2017 7:17 pm
by wjp
SS88 wrote:If you still cannot get the template to work, here is another solution:

Create a new file like so:

Code: Select all

/home/USER/conf/web/nginx.vestacp.com.conf
Add this code in:

Code: Select all

if ($scheme = http) { return 301 https://vestacp.com$request_uri; }
Where USER and vestacp.com are - replace with real username and domain name.
Grateful thanks to SS88 for this. This solution is beyond my current understanding of how nginx config works, but it provides a complete solution for my needs.

Thank you!