Learn about Centmin Mod LEMP Stack today
Become a Member

Xenforo Xenforo friendly URLS 404 errors + general questions

Discussion in 'Forum software usage' started by brainlet2000, Jan 21, 2020.

  1. brainlet2000

    brainlet2000 New Member

    10
    0
    1
    Jan 21, 2020
    Ratings:
    +0
    Local Time:
    2:16 AM
    1.17.7
    10.3.21
    I've tried adjusting my config many times following the rewrite guides on here but I'm confused. When I enable the friendly urls option in Xenforo I just get 404s. I'm kind of desperate at this point as I've literally tried 100 different things. Below is my non ssl nginx config. I don't understand what is wrong as I literally copied it from the centmin guides. I edited out my domain name for privacy purposes.

    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name xx.net;
                return 301 $scheme://www.xx.net$request_uri;
           }
    
    server {
     
      server_name xx.net www.xx.net;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      add_header X-Xss-Protection "1; mode=block" always;
      add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
      #add_header Feature-Policy "accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment 'none'; usb 'none'";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/xx.net/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/xx.net/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/xx.net/autoprotect-xx.net.conf;
      root /home/nginx/domains/xx.net/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      # prevent access to ./directories and files
      #location ~ (?:^|/)\. {
      # deny all;
      #}
    
     location / {
         index index.php index.html index.htm;
         try_files $uri $uri/ /index.php?$uri&$args;
    }
    
    location /install/data/ {
         internal;
    }
    
    location /install/templates/ {
         internal;
    }
    
    location /internal_data/ {
         internal;
    }
    
    location /library/ {
         internal;
    }
    
    #xenforo 2 uncomment / remove hash from next 3 lines
    location /src/ {
         internal;
    }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    Another thing I don't generally understand are the SSL certificates.. I basically just installed my website with menu option 2 without SSL then use cloudflare for ssl. Is this fine or do I need the SSL certificate stuff? I wish I would've seen this great thread: https://community.centminmod.com/th...on-centmin-mod-123-09beta01-lemp-stack.16060/ earlier as I could've just followed the steps.. Now I already have the site up and I'm stuck.

    Can anyone help me out here? I was thinking of just following the steps here https://centminmod.com/vhost.php and enabling SSL with those steps but I'm worried ill brick my server..

    What are the exact steps I should follow if I have already installed my forum with menu option 2, have cloudflare for SSL and want to enable friendly urls + let's encrypt SSL. Is this even possible with cloudflare?

    Also what would be the further steps to optimize as in the guide above? I'm just confused because I feel that I'm too dumb to figure this out without following a step by step guide. It really annoys me.
     
    Last edited: Jan 21, 2020
  2. brainlet2000

    brainlet2000 New Member

    10
    0
    1
    Jan 21, 2020
    Ratings:
    +0
    Local Time:
    2:16 AM
    1.17.7
    10.3.21
    I hate being stupid like this.. It really irritates me that I have to ask to be spoonfed but I just really can't figure this out. I've tried for weeks now.
     
  3. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    11:16 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    That would be fine as Cloudflare uses flexible SSL by default so it talks to non-HTTPS port 80 of Centmin Mod Nginx which is what you setup via centmin.sh menu option 2 when you select without SSL.

    There's generally 3 ways of setting up HTTPS SSL certificate for Centmin Mod Nginx HTTP/2 based HTTPS. You can't use method 1 or 2 now that you created your nginx vhost site, but can use method 3 for existing non-HTTPS nginx vhost migration to HTTPS if you choose to do so later down the road after you sorted out the rest.

    Method 1. The traditional way via centmin.sh menu option 2, 22 but ensuring you set LETSENCRYPT_DETECT='y' in persistent config file created at /etc/centminmod/custom_config.inc before you run centmin.sh menu option 2 or 22 for wordpress. You can do that using command below - only need to do this step once and every subsequent run of centmin.sh menu option 2 or 22 will have letsencrypt ssl certificate support enabled
    Code (Text):
    # enable letsencrypt ssl certificate integration https://centminmod.com/acmetool/
    touch /etc/centminmod/custom_config.inc
    echo "LETSENCRYPT_DETECT='y'" >> /etc/centminmod/custom_config.inc
    


    Method 2. Using and testing Centmin Mod 123.09beta01's new addons/acmetool.sh addon which is still in beta testing only for integrating Letsencrypt SSL certificates. And has both auto and manual methods.

    Method 3. Fully manual method for free Letsencrypt SSL certificates.
    For Xenforo see https://community.centminmod.com/th...nginx-friendly-url-rules-configuration.14289/ though there's a note for differences in vhosts generated if you used that vhost.php generator as opposed to https://centminmod.com/nginx_configure_xenforo_seo_friendly_urls.html
    Did you install Xenforo on web root at domain.com or subdirectory like domain.com/community as that would change the try_files rule for
    Code (Text):
           location / {
               index index.php index.html index.htm;
               try_files $uri $uri/ /index.php?$uri&$args;
    
           }
    

    to
    Code (Text):
           location /community/ {
               index index.php index.html index.htm;
               try_files $uri $uri/ /community/index.php?$uri&$args;
    
           }
    
     
    • Like Like x 1
  4. brainlet2000

    brainlet2000 New Member

    10
    0
    1
    Jan 21, 2020
    Ratings:
    +0
    Local Time:
    2:16 AM
    1.17.7
    10.3.21
    Hi, thanks for the swift reply.. Is there any point in migrating to https on the server when already using cloudflare? Any benefits? Because I already envision myself wrecking my whole dedicated server config.. I haven't figured out how to backup yet and there's no snapshots since it's a dedicated.. Is following that guide safe? I mean of course it is but what's the chance of fucking something up?

    I installed it on web root at domain.com, no sub folder. So I really don't understand why it doesn't work. I put in the rules, restarted nginx, then turned on friendly urls in Xenforo and immediately get 404 errors.. Is there anything wrong with my config file?
     
  5. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    11:16 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Yes if you have HTTPS on Centmin Mod Nginx side, then Cloudflare servers when switched from Cloudflare Flexible SSL to Full SSL, can communicate with Centmin Mod Nginx over HTTPS via TLSv1.3 which is better for performance and security https://community.centminmod.com/th...s-tls-1-3-backend-origin-communication.16795/

    not that I can see. Make sure you uploaded all XF 2.1 files and didn't miss any and ensure permissions are correct as nginx user/group.

    Best way then is start up another hourly billed VPS like vultr, digitalocean, linode or like highly recommended Upcloud - signees also get US$25 credits to use as well as a test VPS and install test Xenforo forum on that as non-HTTPS centmin.sh menu option 2 created site like you have now and then do test method 3 manual migration to HTTPS on that test VPS until you get it all working and comfortable doing on live/production VPS

    That is usually how I test new things, on a test VPS before applying it on live VPS.
     
  6. Rake-GH

    Rake-GH Premium Member Premium Member

    56
    25
    18
    Jul 29, 2019
    USA
    Ratings:
    +42
    Local Time:
    8:16 PM
    default
    default
  7. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    11:16 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    no required as centmin mod nginx vhosts use php.conf include file
    Code (Text):
    include /usr/local/nginx/conf/php.conf;
    
     
  8. brainlet2000

    brainlet2000 New Member

    10
    0
    1
    Jan 21, 2020
    Ratings:
    +0
    Local Time:
    2:16 AM
    1.17.7
    10.3.21
    I will try to implement HTTPS later on a test server first, but what is realistically the chance of any issues if I simply follow your steps? Can't be that hard right?

    I used a fresh install of XF 2.1 and imported from mybb 1.8. I followed your guide to chmod the correct files. It still doesn't work. I really don't get it.
     
  9. brainlet2000

    brainlet2000 New Member

    10
    0
    1
    Jan 21, 2020
    Ratings:
    +0
    Local Time:
    2:16 AM
    1.17.7
    10.3.21
  10. brainlet2000

    brainlet2000 New Member

    10
    0
    1
    Jan 21, 2020
    Ratings:
    +0
    Local Time:
    2:16 AM
    1.17.7
    10.3.21
    Hey guys, I managed to fix this issue. I had my cloudflare settings on SSL strict which made every page only grab the https config which I hadn't set up yet.. By moving it to flexible I was able to enable SEO urls successfully :). Wooo!

    One more question @eva2000, is it a problem enabling SEO links now with flexible ssl by cloudflare? Will there be an issue when I add the SSL certificate? Are the steps any different?

    AKA I'm worried that now all the thread urls are SEO that when I switch to https and there are no rewrite rules this will be broken.. Is this a valid concern or irrelevant?
     
  11. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    11:16 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    ah ha yes that would cause problems when you do not have Centmin Mod Nginx with HTTPS setup yet

    shouldn't be any problems with CF flexible SSL if Centmin Mod Nginx is non-HTTPS nor will there be problem with CF full ssl if you have Centmin Mod Nginx with HTTPS setup eventually.

    non-pretty urls will redirect to pretty ones via Xenforo's own code.
     
  12. Rake-GH

    Rake-GH Premium Member Premium Member

    56
    25
    18
    Jul 29, 2019
    USA
    Ratings:
    +42
    Local Time:
    8:16 PM
    default
    default
    To get the Xenforo 2 Friendly Redirects to work with the official Xenforo 2 Vbulletin -> XF redirect addon you have to do an "unofficial" fix which involves changing:

    Code:
    try_files $uri =404;
    
    to
    Code:
    try_files $uri /index.php?$uri&$args;
    

    view it in full here:
    Code:
    location ~ \.php$ {
      #vbulletin redirect partial fix:
      try_files $uri /index.php?$uri&$args;
     
      #original:
      #try_files $uri =404;
     
      fastcgi_pass    127.0.0.1:9000;
      fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include         fastcgi_params;
    }
    It makes the vbulletin redirects work on XF but it causes some weird PHP errors. Sadly XF is not providing support for this addon.

    Do you think it might have something to do with your php.conf and the unofficial fix being redundant or being incompatible?
     
    • Informative Informative x 1
  13. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    11:16 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    which add on is that ? link url ?
     
  14. Rake-GH

    Rake-GH Premium Member Premium Member

    56
    25
    18
    Jul 29, 2019
    USA
    Ratings:
    +42
    Local Time:
    8:16 PM
    default
    default
    • Informative Informative x 1
  15. eva2000

    eva2000 Administrator Staff Member

    43,132
    9,792
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,122
    Local Time:
    11:16 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    thanks for the heads up. I haven't tried vBulletin to XF 2.x redirections yet only vBulltin to XF 1.5.x redirects and usually I just use pure nginx rewrite rules without any XF vB to XF redirect addons.