How do erase the contents of a error.log file but keep the file intact

You can use this:

>error.log

(typed just like that - an empty output redirection)

or

truncate -s0 error.log

You'll confuse the daemon. Erase the file then send SIGHUP to nginx.