Unmanned Aerial Vehicles (UAVs) are expected to play an active role in future wireless communication systems, thanks to their excellent mobility. This letter considers a problem of navigating a UAV to secure its wireless communication with a stationary or mobile ground node in the presence of stationary or mobile eavesdroppers that can eavesdrop individually and collaboratively. We optimize online the 3D trajectory of the UAV to minimize the energy expenditure of the UAV subject to the UAV's aeronautic maneuverability, and the ground node can effectively capture the transmitted data while the eavesdroppers are not able to do it. A model predictive control (MPC) based navigation scheme is developed and its optimality is proved. Computer simulations and comparisons against a benchmark method are conducted to demonstrate the effectiveness of the proposed approach.