Page 1 of 1

How Do I Add Permalinks Support on SSL with Nginx?

Posted: Mon Oct 17, 2016 4:53 pm
by lotusming
Running a wordpress site on Nginx with PHP-FPM. How do I get permalinks to work correctly with SSL from letsencrypt? My config is below that generates 404 when permalinks are enabled:

Code: Select all

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

server {
    listen      443 ssl;
    server_name example.com www.example.com;
    root        /home/admin/web/example.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/example.com.log combined;
    access_log  /var/log/nginx/domains/example.com.bytes bytes;
    error_log   /var/log/nginx/domains/example.com.error.log error;

    location / {

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

        location / {
    try_files $uri $uri/ /index.php?$args;
}
        client_max_body_size 50M;

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

            fastcgi_pass    127.0.0.1:9001;
            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 /.well-known/acme-challenge {
    default_type text/plain;
    root /etc/letsencrypt/webroot;
}

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

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

# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
}

    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.example.com.conf*;
}


Re: How Do I Add Permalinks Support on SSL with Nginx?

Posted: Thu Oct 20, 2016 6:27 pm
by lotusming
One thing I hate about this forum. People barely answer you. Incase you have the same problem here's the solution.

edit these two files:

Code: Select all

/home/username/conf/web/snginx.conf

Code: Select all

/home/username/conf/web/nginx.conf
add this inside the location block

Code: Select all

try_files $uri $uri/ /index.php?$args;

Re: How Do I Add Permalinks Support on SSL with Nginx?

Posted: Fri Oct 21, 2016 8:13 am
by mehargags
Do you even realize that the question you asked had NOTHING TO DO with VestaCP ? It is a dumb-down NGINX question and before going in for Nginx + PHP-FPM setup you should have done your research and known the fact how to parse your Apache htaccess rules which are NOT honored by Nginx.

Many of us devote our valuable work hours... but sometimes things get a hit or a miss.
Being rude on any public forum is going to get you nothing out... Its a community service.! Research

Re: How Do I Add Permalinks Support on SSL with Nginx?

Posted: Fri Oct 21, 2016 2:46 pm
by lotusming
The only reason you answered bud was because of the first line in my post. Information is not organized properly here so I will ignore your "do research" plug. VestaCP changes many things from how it's normally done in nginx hence the need to ask!

Now since you're on your valuable work hours, you can skip this reply as well and "have a good day".

Re: How Do I Add Permalinks Support on SSL with Nginx?

Posted: Fri Oct 21, 2016 5:13 pm
by mehargags
You are welcome to post suggestions, the community needs your contribution...in whatever aspect you feel - though with some positive attitude. Words do matter, they make or break worlds!