Hello risturiz,
you can use sub_filter directive to rewrite your assets URL on the fly with Nginx.
You may have to put this directive inside the block location / {} if it doesn't work after creating a file cdn.conf in /var/www/yourdomain.tld/conf/nginx with the following content :
sub_filter 'example.com/wp-content/uploads' 'cdn.example.com/wp-content/uploads';
sub_filter_once off;