I set up an About Us resource page in Manager and can only see the page at /index.php?=2 (but only on Firefox - not on Google Chrome or Edge). I cannot see the page at /about
I’ve got Use Friendly URLs, Use Strict Friendly URLs and Use Friendly Alias Path all set to ‘Yes’. The below is my NGINX server config file. Can someone please take a look and suggest where they can see I am going wrong with this?
I don’t have an answer for you, but I added some back-ticks around your code to preserve the formatting and make it easier to read. I hope you don’t mind.
Just checking the basics, but in the configuration you pasted it has “domain” generically. Are you passing traffic on a specific domain? I would expect to see the actual host name there. If you just changed it for the post that’s fine, but wanted to make sure.
Thanks for asking jaredfhealy. I changed it for the post to conceal the real domain name, for the usual obvious security purposes. I did the same with the listening IP (00.0.000.000, etc).
So, typing out a reply… I got to the very end and realized your rewrite is missing the arguments “&$args” which might be causing some issue. Also, I think that the format presented in the docs is outdated. Even within Modx Cloud hosting, they use the try_files directive and fall back on a named location. I have mine in two files, but you could also have the named location defined inline where I am doing the include modx.conf.
Note: After doing all this setup I decided, “Nah, I don’t want to manage the server.” And I moved it to A2hosting.
I followed this Digital Ocean setup guide for Nginx:
So, I’m not sure if it will be helpful or not, but here’s the NGINX setup that I used that worked fine. I notice you have quite a few extra parameters in your FastCGI config. I am using basically the vanilla/recommended starting configuration which has only 2 lines to process PHP. I didn’t have any issues, but you may have those details in there for a reason as I am fairly new to Nginx configurations.
This was on a server that had multiple MODX sites, so I set up two additional configuration files that I pulled into each /sites-available conf: restrictions.conf and modx.conf.
I also used Certbot to make the certificate generation much easier. So that portion of the config is set automatically when you run the Certbot process.
server {
server_name domain.com domain2.com www.domain3.com sub.domain.com;
root /var/www/grv0003/sites/$host;
index index.php index.html index.htm;
include /etc/nginx/global/restrictions.conf;
include /etc/nginx/global/modx.conf;
access_log /var/log/nginx/grv0003/access.log;
error_log /var/log/nginx/grv0003/error.log;
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location / {
try_files $uri $uri/ @modx-rewrite;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($scheme = 'http') {
return 301 https://$host$request_uri;
}
# Remove www
if ($host = www.$host) {
return 301 https://$host$request_uri;
}
listen 80;
listen [::]:80;
server_name domain.com domain2.com www.domain3.com sub.domain.com;
return 404;
}
And then the modx.conf file that is included from the /global folder I created. This allows additional sites to pull in shared configuration but is not needed. This could be defined within the same /sites-available conf file.
I really appreciate your time in looking at this. The actual rewrite ‘args’ appears on line 10 with rewrite ^/(.*)$ /index.php?q=$1 last; which obviously did not work. I will try the various suggestions in the code you presented and post what I find.
The other ‘outdated’ and somewhat convoluted code perform various functions and is there to provide backward compatibility and security.
I think it would only affect the manager possibly or paging if you were using that, but what I meant was on line 10 you are missing $args which contains the rest of the query parameters. The $1 just contains the path that was matched by the regex:
rewrite ^/(.*)$ /index.php?q=$1 last;
-------------- Should be ------------------
rewrite ^/(.*)$ /index.php?q=$1&$args last;
I stepped away from the internet over the New Year and holiday period but thanks, once again jaredfhealy, for helping me understand things clearer.
I like the idea of using include files as I do want to host more sites using Modx, once I have the /subfolder configuration working. Could you help me further by showing me what you’ve got in the following files:
include /etc/nginx/global/restrictions.conf;
include /etc/nginx/global/modx.conf;
Like you I’m a relative newcomer to nginx (a few months ago) but I get the concept and learning it makes using it more fun, once I untangle certain parts of it.
I unfortunately don’t have the server anymore. But you can refer to this Modx Support article that has some Security rules. Scroll down to point #6 in the list. I was using that restrictions file to include things like this. I only had a couple items in there I was testing out.
Thanks for the link. I’ve seen the content of what typical global restrictions.conf and modx.conf files look like. You’ve placed yours in a ‘global’ sub-folder. My setup did not generate a /global sub-folder automatically. I guess I have to create it manually…
Hi there,
this is interesting for DigitalOcean case, i.e I have tried several option for config but it never loads the friendly url, always not found page.
Please see my test domain nginx config for MODX revolution 2.8.5