I'm having a webpage that loads inside an iframe. I added the base tag to load the images, styling and to make links work, after clicking on a link I'm getting the error "whatsmyip.com refused to connect". Adding target="name-of-iframe" to all links doesn't work.

HTML

 <html>
    <head>
    <script type="text/javascript" src="jquery-3.2.1.min.js"></script>
        <script>
            function getURL(url){
                document.getElementById('frame').src  = 'proxy.php?url='+encodeURIComponent(url);
            }
        </script>
    </head>
    <body>
        <button onclick="getURL( 'https://whatsmyip.com/')">Google</button>
        <iframe name="frame" id="frame" width="800" height="600" src=""></iframe>
    </body>
</html> 

PHP

    $page = get_page($_GET['url']);

    $page = str_replace("<head>","<head><base href=\"".$_GET['url']."\">",$page);

    echo str_replace("<a","<a target=\"frame\"",$page);

    function get_page($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);

        $proxy = '14.207.72.213:8080';
        curl_setopt($ch, CURLOPT_PROXY, $proxy);

        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }