Rewrite server code to proxy