XF 2.0 Possible NGINX config issue?

bostoneo

New member
So I am setup such that my install references everything without the WWW.

My DNS records have a CNAME that points the www to base A record.

My NGINX config looks like so:

Code:
server {
        server_name societyofsmoke.com;
        root /var/www/html/;

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

location = / {
        return 301 http://societyofsmoke.com/community/;
}


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

location /community/install/data/ {
        internal;
}

location /community/install/templates/ {
        internal;
}

location /community/internal_data/ {
        internal;
}

location /community/library/ {
        internal;
}

location /community/src/ {
        internal;
}

location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}

}
now if you hit my forum at societyofsmoke.com it sends you to societyofsmoke.com/community and everything works. if you try the www it does the same. HOWEVER, on occasion for some reason I end up at www.societyofsmoke.com (not sure why) and when I do everything that I click on gets 404'd.

This what my NGINX access.log shows during the failures.

8.41.66.66 - - [19/Jun/2018:00:02:52 -0400] "GET /community/forums/introductions.10/ HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"
8.41.66.66 - - [19/Jun/2018:00:02:55 -0400] "GET /community/forums/introductions.10/ HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"


And during success:

174.224.135.101 - - [19/Jun/2018:11:16:13 -0400] "GET /community/forums/introductions.10/ HTTP/1.1" 200 20387 "http://societyofsmoke.com/community/" "Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Mobile Safari/537.36"
174.224.135.101 - - [19/Jun/2018:11:16:14 -0400] "POST /community/job.php HTTP/1.1" 200 24 "http://societyofsmoke.com/community/forums/introductions.10/" "Mozilla/5.0 (Linux; Android 8.0.0; SM-G955U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Mobile Safari/537.36"


I'm certain there's something with my NGINX config thats getting me - I just dont know what.

EDIT: if this post is in the wrong forum let me know and I'll re-do it elsewhere -but I figured here would be a good place for issues with a fresh install.
 
Last edited:

Vekseid

Member
You want an extra server block to catch your www address.

Code:
  server {
    server_name *.societyofsmoke.com;
    rewrite ^ $scheme://societyofsmoke.com$request_uri  last;
  }
 
Top