Join the community today
Register Now

Xenforo 404 pages do not display XenForo error pages, instead just showing the nginx error

Discussion in 'Forum software usage' started by rdan, Jun 3, 2014.

  1. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    10:11 AM
    Mainline
    10.2
  2. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Fixed it manually with custom 404.html redirect via Nginx. No need for Xenforo/PHP-FPM to handle 404s. Try it now on this forum :D

    Code:
    ls -lah | grep 404.html
    -rw-r--r--  1 nginx nginx 130K Jun  2 20:19 404.html
    the 404.html is just a static html page with custom style matching the forums ;)

    Code:
            error_page 404 /404.html;
    
            location = /404.html {
                    access_log              off;
                    internal;
            }
    Code:
    curl -I http://community.centminmod.com/test404
    HTTP/1.1 404 Not Found
    Server: nginx centminmod
    Date: Mon, 02 Jun 2014 20:23:41 GMT
    Content-Type: text/html; charset=utf-8
    Connection: close
    Vary: Accept-Encoding
     
    Last edited: Jun 3, 2014
  3. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    did a custom one for /403.html now too :D

    Code:
            error_page 403 /403.html;
            error_page 404 /404.html;
    
            location = /404.html {
                    access_log              off;
                    internal;
            }
    
            location = /403.html {
                    access_log              off;
                    internal;
            }
    screenshot403.jpg
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    And 504 custom page :D

    Code:
            error_page 403 /403.html;
            error_page 404 /404.html;
            error_page 504 /504.html;
    
            location = /504.html {
                    access_log              off;
                    internal;
            }
    
            location = /404.html {
                    access_log              off;
                    internal;
            }
    
            location = /403.html {
                    access_log              off;
                    internal;
            }
     
  5. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    10:11 AM
    Mainline
    10.2
    The beauty of XenForo 404, 403 errors, the menu is dynamic.
    Different header menu for login and guest :)
    So I will not use static html for this :(
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    oh in that case just remove the image extension matching location from /usr/local/nginx/conf/staticfiles.conf :)
     
  7. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  8. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    10:11 AM
    Mainline
    10.2
    Some of googles advice :)

    Here are some suggestions for creating an effective 404 page that can help keep visitors on your site and help them find the information they're looking for:
    • Tell visitors clearly that the page they're looking for can't be found. Use language that is friendly and inviting.
    • Make sure your 404 page uses the same look and feel (including navigation) as the rest of your site.
    • Consider adding links to your most popular articles or posts, as well as a link to your site's home page.
    • Think about providing a way for users to report a broken link.
    • No matter how beautiful and useful your custom 404 page, you probably don't want it to appear in Google search results. In order to prevent 404 pages from being indexed by Google and other search engines, make sure that your webserver returns an actual 404 HTTP status code when a missing page is requested.
    • Use the Enhance 404 widget to embed a search box on your custom 404 page and provide users with useful information to help them find the information they need.

    So your lucking this:
    • Make sure your 404 page uses the same look and feel (including navigation) as the rest of your site.
     
  9. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    updated the layout a tad with theme's header :D
     
  10. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  11. Derek

    Derek Member

    47
    9
    8
    Aug 5, 2016
    Ratings:
    +22
    Local Time:
    10:11 PM
    So I'm looking to fix my 404 error pages now that I've migrated from vB -> Xenforo, and I see the same white default nginx 404 pages here that I see on my site.

    For someone who's comfortable with Apache (hah!) and is new to Xenforo, what needs to be done on centminmod so that Xenforo handles bad links itself?
     
  12. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    10:11 AM
    Mainline
    10.2
     
  13. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  14. Derek

    Derek Member

    47
    9
    8
    Aug 5, 2016
    Ratings:
    +22
    Local Time:
    10:11 PM
    Thanks folks. I didn't find the solution I was looking for, but I did find one that was acceptable, and that's good enough. :D
     
  15. Derek

    Derek Member

    47
    9
    8
    Aug 5, 2016
    Ratings:
    +22
    Local Time:
    10:11 PM
    Fixed this. For the next person looking this up:

    Symptoms
    • People going to old links, like the old vBulletin /usercp, were getting 404 errors that didn't say much. Some were thinking the new software wasn't up yet.
    • If you bookmarked something that required being logged in, like the watched threads page, then tried to get there when you weren't logged in, you'd get a 403 error page.
    • The initial fix was to comment uncomment the include /usr/local/nginx/conf/errorpage.conf; line in my nginx config for the domain. Then I edited those pages to have my logo, changed the text, etc. It wasn't a fix, but it was better.
    • Now Xenforo is handling these itself. I needed to add this code to handle rewrites:
    Code:
       location / {
                index index.php index.html index.htm;
                try_files $uri $uri/ /index.php?$uri&$args;
           
            }
    
            location /internal_data/ {
            internal;
            allow 127.0.0.1;
            allow YOURIPADDRESS;
            deny all;
            }
    
            location /library/ {
            internal;
            allow 127.0.0.1;
            allow YOURIPADDRESS;
            deny all;
            }
    (Note: it's obvious, but change YOURIPADDRESS to something meaningful in your situation. For mine I added 2 lines here, for each of the machines that need access.)

    I guess I should have done this first, but I don't know that I care about rewritten thread names, and that's all I thought was happening.

    So, fixed. Have fun.
     
  16. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yup listed at Nginx Configuration Examples - CentminMod.com LEMP Nginx web stack for CentOS

    specifically for xenforo Nginx Rewrites for Xenforo Friendly Urls - CentminMod.com LEMP Nginx web stack for CentOS :)
    errorpage.conf include file is usually commented out by default when nginx vhost is generated :)
     
  17. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    10:11 AM
    Mainline
    10.2
    What I did now was just add this config:
    Code:
    error_page 404 /xf_404;
    /xf_404 is just a dummy/random 404 page uri.

    So all my 404 page will be serve by xenforo and also 404 links with static file extensions.
     
  18. eva2000

    eva2000 Administrator Staff Member

    53,614
    12,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,683
    Local Time:
    12:11 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Interesting approach there :)
     
  19. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    10:11 AM
    Mainline
    10.2
    I tired pointing it to a real xenforo page uri but it doesn't work, not sure why.
     
  20. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    10:11 AM
    Mainline
    10.2
    After doing this, my Google SEO has increased a lot.
    Traffic/Unique Visitors/Search Appearance and Clicks & Revenue was doubled.