consolidate proxy logic to setup_proxy