-1

I have a img label embed a image path of mine public server, and show the image to users:

<img src="http://13.43.68.1:8000/img/gen/trafiic.png">

but this is security risk, because users can get my image source server(13.43.68.1).

So, is there any method to let users can not get the IP? such as cache the image data, just show the cached img data as src.


Edit-01

I am under the image.tpl, smarty template of PHP:

<div class="panel-body text-center">
    <h4>Daily</h4>
    <img width="360" src="http://13.43.68.1:8000/img/gen/trafiic.png.php?switch={$switch}&port={$portname}&cycle=-1d"><br><br>
    <h4>Weekly</h4>
    <img width="360" src="http://13.43.68.1:8000/img/gen/trafiic.png.php?switch={$switch}&port={$portname}&cycle=-1w"><br><br>
    <h4>Monthly</h4>
    <img width="360" src="http://13.43.68.1:8000/img/gen/trafiic.png.php?switch={$switch}&port={$portname}&cycle=-1m"><br><br>
</div>

in this case, how to hidden the src IP?

user7693832
  • 6,119
  • 19
  • 63
  • 114

3 Answers3

1

I'd say your IP being exposed is not particularly a security flaw. You can get the IP address of any server whether its backed by a hostname or not. I'd recommend purchasing a domain name (or mapping the subdomain of an existing domain) and pointing it using an A record to your image servers IP address.

You'd then be able to access your images by going to http://fakedomain.com:8000/img/gen/trafiic.png for example.

While you could convert all of your images to base64 and output them that way, your source code will grow - it's better to keep separate requests :)

Alternatives:

  • use a middle man such as Cloudflare to prevent exposing your IP address
  • base64 - but wouldn't recommend as its expensive on page load (but then depends on your needs)
  • use a script to generate and offload your graphs to somewhere like Amazon S3 and load from there.
Chris
  • 1,939
  • 1
  • 19
  • 38
-1

If the source gives the image URL to you, you can get URL content and encode it in base64. Check the code below:

$imgURL = 'https://via.placeholder.com/350x150';
$imageData = file_get_contents($imgURL);

$imgSrc = 'data:image/png;base64,' . base64_encode($imageData);

return '<img src="'.$imgSrc.'">';
-1

you could use this solution to convert your image to base64 and decode the base64 as src instead of using url

Erfan Mola
  • 111
  • 1
  • 11