[nginx] Default avatar for missing images after migration

  • I'll make this as simple as it can be, after importing your forum it might come a problem when you see some of your users avatars broken, here's a simple method to set a placeholder image for missing images.

    • First you have to upload your default image anywhere on the public directory, I would suggest in public/uploads/default.png, the full path should be /path/to/nodebb/public/uploads/default.png.

    • Now you have to get the default avatar directory for your imported forum, to get this path right click on the avatar of your broken user and click copy image location, paste it in a text file, in my case it was example.com/assets/uploads/xenforo/data/avatars/m/0/84.jpg so the path should be the folder containing all avatars /uploads/xenforo/data/avatars you have to lose the assets folder from the path.

    • In your nginx conf add this block under the main block /:

      location /uploads/xenforo/data/avatars {
        try_files $uri /uploads/xenforo/data/avatars/default.png;

      Full nginx conf should look something like this:

      upstream nodebb {
      server {
        server_name example.com www.example.com;
        root /path/to/nodebb/public;
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://nodebb;
            proxy_redirect off;
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            location /uploads/xenforo/data/avatars {
              try_files $uri /uploads/xenforo/data/avatars/default.png;

    Hope this helps someone. 🙂

Suggested Topics

| | |

© 2014 – 2022 NodeBB, Inc. — Made in Canada.