Nginx, MODx & Xenforo, living together -> .conf challenge

143 views Asked by At

I have having a great deal of difficulty configuring nginx to serve both Xenforo and MODx from the one domain. I have tried hundreds of adjustments, read everything I can and almost have it working correctly... but no cigar.

The crux of the issue appears to be the MODx rewrite hijacks my xenforo /xf/ location and no /xf/ URL's will resolve whatsoever, instead they trigger the MODx default 404 error page.

Full server block is;

server {

## HTTPS server essentials
listen  443;
server_name  www.mysite.com.au;

## Common Server block SSL config 
include "/opt/bitnami/nginx/conf/bitnami/ssl-apps.conf";    



## Xenforo location
location ^~  /xf/   {
    root /opt/bitnami/apps/xenforo;

    ## SEO friendly urls    
    try_files $uri $uri/ /xf/index.php?$uri&$args;

    location ~ \.(php)$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_read_timeout 300;
        fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
        fastcgi_index index.php;
        fastcgi_ignore_client_abort on;
        fastcgi_param  SCRIPT_FILENAME $request_filename;
        include fastcgi_params;
    }

}


## MODx 
root /opt/bitnami/apps/mysite.com.au/htdocs;

try_files $uri $uri/ ;

    location ~ \.(php|html)$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_read_timeout 300;
    fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
    fastcgi_index index.php;
    fastcgi_ignore_client_abort on;
    fastcgi_param  SCRIPT_FILENAME $request_filename;
    include fastcgi_params;
    }

    if (!-f $request_filename) {
    rewrite ^/(.*)$ /index.php?q=$1 last;
    }

}

HOWEVER, if I change the MODx regex rewrite to;

 ^/(.*).html$ 

Then 100% of the xenforo URI's resolve and everything nearly works except MODx directory uris without trailing /index.html do not resolve (ie www.mysite.com.au/content1/ will fail).

I have studied the labyrinth of cascading priority and committed to test at least 80 or more variations over the last 10 hours. I can not get the /xf/ path to live nice with the MODx rewrite no matter what I try.

I need the directories paths to resolve for a bunch of reasons, not least of which is years of SEO work.

Any advise appreciated

1

There are 1 answers

0
ericTbear On

got it working with;

rewrite ^/(.*).html$ /index.php?q=$1 last;