Refactor reverse proxy