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 RoldanLT, Jun 3, 2014.

  1. RoldanLT

    RoldanLT Well-Known Member

    3,787
    928
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,252
    Local Time:
    4:46 AM
    1.11
    10.2
    • Like Like x 1
  2. eva2000

    eva2000 Administrator Staff Member

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
    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

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
    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

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
    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. RoldanLT

    RoldanLT Well-Known Member

    3,787
    928
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,252
    Local Time:
    4:46 AM
    1.11
    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

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
    oh in that case just remove the image extension matching location from /usr/local/nginx/conf/staticfiles.conf :)
     
    • Like Like x 1
  7. eva2000

    eva2000 Administrator Staff Member

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
  8. RoldanLT

    RoldanLT Well-Known Member

    3,787
    928
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,252
    Local Time:
    4:46 AM
    1.11
    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

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
    updated the layout a tad with theme's header :D
     
  10. eva2000

    eva2000 Administrator Staff Member

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
    • Agree Agree x 1
  11. Derek

    Derek New Member

    28
    9
    3
    Aug 5, 2016
    Ratings:
    +16
    Local Time:
    4:46 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. RoldanLT

    RoldanLT Well-Known Member

    3,787
    928
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,252
    Local Time:
    4:46 AM
    1.11
    10.2
     
    • Agree Agree x 1
  13. eva2000

    eva2000 Administrator Staff Member

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
  14. Derek

    Derek New Member

    28
    9
    3
    Aug 5, 2016
    Ratings:
    +16
    Local Time:
    4:46 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 New Member

    28
    9
    3
    Aug 5, 2016
    Ratings:
    +16
    Local Time:
    4:46 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

    27,771
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    6:46 AM
    Nginx 1.13.x
    MariaDB 5.5
    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 :)