added logic to support setups using apache, with/without nginx, with/without port forwarding