One, chmod -R 777 is a terrible idea. It can also cause issues if the program has any security checking at all.
second, there is no issue between nginx and flarum. It's likely a mis-configuration.. Especially since nginx does very little with flarum at all and is mostly served by php-fpm (if you use that).