Page 1 of 1

HTTPS/SSL Issue

Posted: Sat Jul 23, 2016 10:01 pm
by alikamran
I am having issues setting up SSL for one of my website. First of all, let me explain my setup; I am running CentOS 7, Nginx, PHP-FPM, and Vesta CP. The website I am trying to setup is built on WordPress and uses CloudFlare. I have completely installed the SSL certificate (StartSSL) on the domain in Vesta CP. Then I turned the CloudFlare SSL setting to "Full (Strict)" and installed a WP plugin to force HTTPS across the website. Now with everything setup, the home page of the WordPress website works fine in the https form and the green padlock shows in the browser but as soon as I open a post, it gives a 404 (server's 404 page shows up). Turning off the WP permalinks fixes this issue but permalinks are necessary so I cant turn them off.

I am also attaching my Nginx config file below. After the process mentioned above, the website does not redirect automatically from non-http to https version but if you specifically open the https version, the home page works fine but the posts/pages don't. Furthermore, due to the way I setup the website, the domain in Vesta CP is non-www but previously I was using www version on the old server so I added a redirect in the Nginx config to 301 all non-www requests to www version.

Any help will be highly appreciated.

SpoilerShow
server {
listen xx.xxx.xx.xx:xx;
server_name chiploco.com;
return 301 $scheme://www.chiploco.com$request_uri;
}
server {
listen xx.xxx.xx.xx:xx;
server_name http://www.chiploco.com;
root /home/admin/web/chiploco.com/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/chiploco.com.log combined;
error_log /var/log/nginx/domains/chiploco.com.error.log error;

location / {

location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}

location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name){
return 404;
}

fastcgi_pass 127.0.0.1:9004;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}

error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;

location /error/ {
alias /home/admin/web/chiploco.com/document_errors/;
}

location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}

include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;

include /home/admin/conf/web/nginx.chiploco.com.conf*;
}

Re: HTTPS/SSL Issue

Posted: Tue Jul 26, 2016 8:31 am
by skurudo

Code: Select all

server_name http://www.chiploco.com;
This server_name looks not right.

Code: Select all

server {
listen xx.xxx.xx.xx:xx;
server_name chiploco.com www.chiploco.com;
return 301 https://$server_name$request_uri;
}
server {
listen xx.xxx.xx.xx:xx;
server_name chiploco.com www.chiploco.com;
root /home/admin/web/chiploco.com/public_html;
...