Under the Lens
- Posted by mariteaux on May 25th, 2020 filed in Technologizing
- Comment now »
One of my two potential upgrades to our Gopher server was to be a local proxy server I could link out instead of expecting lazy people to install something to look at my hard work. dcb already had a proxy setup on repl.it called Gopherlens that I could replicate and figured it wouldn’t be hard at all to get working on the Pi alongside Gophew.
How optimistic we were.
Here’s an abridged timeline of events in my first failed attempt to get Gopherlens going on the Pi:
- Much confusion between dcb and I on whether to use the Django version of Gopherlens or the Flask version of Gopherlens. He finally recommends the Flask one.
- I set up a venv and start installing dependencies in it.
- I stumble my way around the Flask documentation but eventually get it running on 127.0.0.1:5000. This is naturally not even remotely the host and port I need.
- After some confusion as to what it wanted for “host”, I run it on 0.0.0.0. Fine enough.
- I try to run it on port 80. It naturally doesn’t let me.
- I try running Flask as root. It forgets what the fuck Pituophis is.
- Setting sudo
-u pi
so it remembers what the fuck Pituophis is throws permission denied despite being root. - I give up on running it directly on 80 and try to run it on 8080 instead. Naturally works.
- I reroute 8080 traffic to 80. Port forward. It seems to work, even on the URL.
- …But in reality, this doesn’t work outside of my network. Not even forwarding 8080 and using that works.
- We check everything–I even scrub through my ISP’s (incredibly minimal, shitty) documentation for blocking port 80 outbound traffic. Nothing.
- It turns 1am. dcb suggests running Apache instead of Flask’s built-in server.
- I go to install packages, only to find that, in my attempt to totally blank the firewall rules temporarily and allow all traffic, I scrubbed the Pi’s DNS setup somehow. (This doesn’t affect the Gopher server, seeing as the DNS for that is handled by DreamHost.)
apt
freaks. - I start moving my only keyboard back and forth between my Mac and the Pi to play around, and somehow, it stops working on my main machine. I have to hard reboot it to even get it to recognize it.
- I at least get DNS working again before going to bed, thoroughly exhausted.
This morning, I gave something else a shot–using our shared hosting and Passenger, a web app deployment server. See, DreamHost offers Passenger on all plans for mostly Ruby on Rails stuff, but Python scripts work through it too. Flask is explicitly mentioned in their documentation. Despite having even less of a clue on someone else’s server than on mine, I got to work installing a custom Python and another venv.
The thing that gets you about Flask isn’t that it’s particularly hard to set up–I got that going within the hour. It’s trying to get it to work like a normal fucking server. If I didn’t care, I could accept running it on 5000 and calling it a day, but I can’t. I want it to take requests on 80. That’s the HTTP port. Even here, I couldn’t seem to get Passenger to take 80 traffic, no matter what I tried. .htaccess
RewriteEngine funny business? No. mod_proxy? VPS hosting only. Passenger is apparently smart enough to take 80 and 443 for node.js, but for Python? No thanks, Samuel.
So then I took a step back and remembered what I do best. Gluing scraps of wood together.
See, DreamHost automatically makes a public/
directory for static files when you enable Passenger, and you can throw a “this app is off or doesn’t work” type of page in there. I instead decided to throw a page in there with a meta redirect to take requests on 80 and forward them automatically to 8080. This worked, but it’s the world’s second-filthiest kludge.
What’s the first?
Yeah, once an hour, I have a cron job going off that starts Flask if it’s not already going. I would set it and forget it, but it seems like closing out of the SSH session also stops what I ran through it. I have to deploy it remotely. This means that if I want to tweak it, I SSH in as myself, pkill Flask
, and wait until the top of the hour to see the results of my work. (Lately, that’s been giving it a splash of color and some fonts work.)
But hey! It’s…up! I guess? I am the world’s worst sysadmin and I probably shouldn’t have been allowed to use anything with preemptive multitasking, let alone a server console, but Gopherlens is functional and I’ll be linking it on the top-level Somnolescent site as a way to get Gopherhole access. Feel free to use it. I’m just very much looking forward to playing with something other than nano. Just you all wait a week…