How to hang a ceiling fan box in gazebo with no parallel joists?
A lot of this comes down to aesthetics and practicality, so you will probably get lots of right answers. Here's my take:
I would run your short piece of 2x4 level at the peak alongside 2 of the rafters. You will then be able to use a saddle fan box to mount your fan. This box slides over the 2x4, and is only fastened using a set screw. You then use wood screws to actually fasten the fan bracket to the 2x4 behind the box, not the box itself.