Nginx, WordPress permalinks, custom configuration

abletec

Verified User
Joined
Sep 14, 2021
Messages
27
First, let me say hello and thanks for this forum. I'm a newby to Directadmin. I am, however, no newby to Nginx.
My WordPress permalinks aren't working for posts and pages. This obviously came as quite a surprise to me, as I've been doing this on Nginx for years.

I have some favorite Nginx coonfiguration entries such as:
location / {
try_files $uri $uri/ /index.php?$args;
}
and
location ~* ^.+\.(jpg|jpeg|png|gif|ico|css|js)$ {
access_log off; # Disable logging
log_not_found off;
expires max;
}

I'd like those entries to be global, as most of my clients do in fact use WordPress. I'd really prefer *not* to have to do this w/every user I set up, but I'm pretty confused about how to do that. I've read about httpd custom templates, but I'm not sure what the template token location_blocks means. I've also read about custom httpd configurations, but I am just really uncertain about how to do this globally as opposed to per user. I'm unsure of the order, as in, how can I include a configuration so it won't be overwritten by items taking precedence over it.

I don't mean this as a criticism, but although you've got a lot of documentation, it just feels kind of scattered and hard to put the pieces together. And, as with all documentation, some has become depricated over time but remains for historical purposes or those using older versions, which adds further to the muddying of the waters.

So, if anyone can provide some insight as to how to go about this, I'd be appreciative. Thanks in advance for any assistance, and have a great rest of your day.
Jackie
 
Thanks, jamgames2. So what are the tokens |LOCATION_BLOCKS| and |EXTRA_LOCATIONS|?
 
The following works, but perhaps there's a more elegant way:

Code:
cd /usr/local/directadmin/data/templates/custom
cp ../nginx_php.conf .
nano /usr/local/directadmin/data/templates/custom/nginx_php.conf

Add the following lines at the bottom:

Code:
location / {
try_files $uri $uri/ /index.php?$args ;
}

Code:
chown diradmin:diradmin nginx_php.conf
cd /usr/local/directadmin/custombuild
./build rewrite_confs
 
The following works, but perhaps there's a more elegant way:

Code:
cd /usr/local/directadmin/data/templates/custom
cp ../nginx_php.conf .
nano /usr/local/directadmin/data/templates/custom/nginx_php.conf

Add the following lines at the bottom:

Code:
location / {
try_files $uri $uri/ /index.php?$args ;
}

Code:
chown diradmin:diradmin nginx_php.conf
cd /usr/local/directadmin/custombuild
./build rewrite_confs
Thanks, wtptrs. When I did that, it actually didn't work for me. The other problem is I have clients (and 1 of them is myself, I admit) who tend to install WordPress in its own folder sometimes, and unfortunately that won't help in that situation either.

What I finally ended up doing is putting the changes in a custom version of nginx-server-secure.conf, and that works under both scenarios. Like you, I'm concerned that this might not be the most elegant solution out there. In this case, until I learn otherwise, elegant is what works. I'd still like to know the meaning of those tokens, however, as I can't find anything in the docs regarding that.

Yall have a great rest of your day, and thanks once again to those who've replied.
 
Back
Top