4

I'm trying to use a Raspberry Pi to remotely view a website. For example, if I have a printer I want to interact with, that hosts a browser user interface and outputs it via USB, I want to be able to connect to that wirelessly from my phone, in my phone's browser.

Currently I am connecting to the printer using a Pi 3 and TightVNC to view the Pi GUI remotely using the Pi's onboard Wi-Fi (to be clear, the Pi isn't connecting to the internet, my phone is just connecting to the Pi's local network). Once I have VNC'd into the Pi, I open the Pi's web browser, then type in the address of the printer (something like http://192.xxx.x.xxx) to access the browser interface. From there, I can do everything I need to (send files to the printer, receiver feedback from the printer when it has printed, etc).

It's a little clunkier than I'd like, and would prefer to just be able to open up a browser in my phone and directly interface with my printer. Is there a way to do that? I'll be both sending commands to the printer as well as getting feedback from it, if that matters.

3
  • I've reopened this since you clarified the situation and, to correct myself from before, this probably isn't as "fairly easy" as I thought at a glance (i.e., without thinking all the way through). It certainly should be possible, but it may require a bit of intermediate software (e.g., a proxy server), and at this point, since that isn't pi specific and we are a relatively small site, you would be better off generalizing the pi out of the scenario and asking on our larger sibling site Unix & Linux.
    – goldilocks
    Commented Jun 7, 2016 at 16:56
  • 1
    Maybe you can port forward the printer to the internet and have a password to prevent others from messing around with it.....
    – Mero55
    Commented Jun 7, 2016 at 21:07
  • 1
    Does the printer offer any sort of connectivity?
    – Mero55
    Commented Jun 7, 2016 at 21:07

1 Answer 1

2

First of all, brilliant idea man! That's the best thing about these little boards like Pi.

Anyway, here's what I suggest:

Exploit the local network! Use the hosts file to assign printer's address to Pi's IP on the network. That way, whenever you enter the address of Pi on your phone browser, it'll actually show the printer's interface.

Quite a mouthful maybe? Okay.

  • SSH into your Pi in whatever way you want. From your phone or laptop or whatever really.

  • sudo nano /etc/hosts

  • Add this line after commenting the existing line with localhost

    192.x.y.z 192.a.b.c

Here the first IP is that of printer, and the second is of your Pi.

  • sudo /etc/init.d/networking restart

If your printer is online and so is your Pi, fire up your phone's browser and type in 192.a.b.c and hopefully you will see what you want.

My own Pi got bricked last week so I cannot try this myself, but I think broadly this approach should work. Possible problems would arise due to dynamic IP assignment after restart of your Pi, so it would need a static IP assigned. I'm not sure about Ports either, so if your printer's browser is running on some pqrs port, then the only change would be adding the port in the URL which you'll type in your phone's browser, that is, it'll become 192.a.b.c:pqrs

This is to the best of my knowledge and experience. I hope it helps you a bit!

Edit: Tried to sort of pull off a similar thing just now. Ran a nginx server on docker and used the hosts file to alias the docker IP with the my system's LAN IP, and accessed this IP using my phone's browser, and voila! I see the nginx welcome page alright. So it should work in your case as well though. Would love to hear about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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