0

My Raspberry PI runs 24/7 and I would like to be able to host images that are stored on that PI for my website. How can I go about doing this? Sorry for the lack of detail, if you have any questions just let me know. Thanks, Oliver

It's a Raspberry PI 3 running Raspberry PI OS (Raspbian) and I would like a HTML link to host the images on (for all over the world, not just local network access)

3
  • 1
    This is overly broad. Pretty much any web server could be used. – Dmitry Grigoryev Jul 1 '20 at 14:37
  • Welcome -- but beyond "web server" this is largely a matter of opinion and debates of that sort do not suit our format. Please take the tour to understand better how the site works. – goldilocks Jul 1 '20 at 15:01
  • Thanks for the support everyone – ekv_56 Jul 2 '20 at 8:04
1

Take a look at Flask (https://flask.palletsprojects.com/en/1.1.x/) as that can be used to host webpages from the Pi. But I do worry about the security of opening up a Pi to the whole world. Once you've opened a port on your router to permit access to the Pi's web pages then all the hackers will also try and get in.

4
  • "all the hackers will also try and get in." -> No, it will mostly be just search engine crawlers. Some of which are fronts for government espionage agencies. It is not hard to keep a web server hosting static content secure. – goldilocks Jul 1 '20 at 14:40
  • @goldilocks Can I open it up to just allow access to certain images. It's not the webpages I want to host, it's the images. Example: on my wordpress site, I can embed or have an image there that is located at my PI. It is at home, yes but is there a way to have a public IP or image host using the storage on my PI as a web server? – ekv_56 Jul 2 '20 at 8:03
  • You already have a public IP address - whatsmyip.org will tell you what it is. Unless your broadband provider gives you a static IP, bear in mind that the address will change dynamically each time the router reboots (and possibly at other times) so cannot be relied upon. So you will also want a name that translates your IP into something static (explanation here ionos.co.uk/digitalguide/server/know-how/…) - there are plenty of free providers. (Part 1- To Be Continued) – PeteC Jul 2 '20 at 12:11
  • You will also then need to install a program on the Pi to maintain the relationship between the broadband IP address and the name you have chosen. An example on Linux is ddclient - I haven't tried on a Pi, but if that's not available then there will be another service that can be used. Finally, make sure you have considered the security - I would read up on making sure that the Pi is secure. – PeteC Jul 2 '20 at 12:15
1

How can I host images for my website on my Raspberry Pi?

As per comments, this is what a web server is for. What's available is mostly dictated by the operating system; presuming you are using Raspbian/RpiOS, that is essentially "linux" and anything from this list with turquoise in the "Software license" column should work. The most popular are Apache and nginx.

If you do any programming at all, most of the popular high level interpreted, dynamically typed languages (python, perl, ruby, javascript, etc) will have an assortment of standalone frameworks that can be used to implement simple web servers. Notable among those is node.js, but again, this is all really a matter of personal preference.

for all over the world, not just local network access

This is potentially tricky depending on where the Pi is. Presuming "your home", a complication is that you do not have a stable IP address there. One solution to this is using a (paid) dynamic DNS service. This is not very expensive. It is not an issue that is particular to the brand of hardware (100% irrelevant) and so you will be better server researching that in a broader context.

Can I open it up to just allow access to certain images

Sure. For obvious reasons web servers must restrict what local resources you can access with them. For example, commonly static stuff is placed in a directory hierarchy that parallels URLs. Eg., if you have a /var/www/images/foo.jpg that's accessed via www.mydomain.net/images/foo.jpg, the server could be set up to allow only content below /var/www/. This is the methodology with Apache, but it is server specific -- others might use a different mechanism. Note the URL there is for a .jpg image not an .html page. These can be embedded in pages served remotely (ie., by another web server); while web browsers may implement some cross-site restrictions for security reasons this would not be considered a risk.

But none of this is pi specific; there is no web server written for the Raspberry Pi, so the best thing to do is research it within that broader context. There may be ten or so million Pis in the world running right now, and that number has been building for almost a decade, but Apache, eg., is probably serving ten times that number of web sites right now and has been a prominent fixture of the internet since the mid ninties.

That's not an endorsement or recommendation of Apache, just trying to illustrate that there's a distinction between your project and the brand of hardware you intent to use with it. Further there's no significant information overlap information between them.

2

Not the answer you're looking for? Browse other questions tagged or ask your own question.