-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nginx proxy #638
base: master
Are you sure you want to change the base?
Add nginx proxy #638
Conversation
The first thing I want to say is I'm not in charge of anything. I don't make the rules and I don't decide whether PRs get accepted or rejected. I'm just another IOTstack user who is trying to help. I mostly respond to PRs and issues because I reckon there's nothing worse than putting in the effort to do something and getting nothing but silence in return. Can I ask whether you've joined the IOTstack Discord channel? You might get help and guidance there too. Speaking 100% personally, I don't "get" the whole idea of nginx. As far as I can tell, it's just a way of being able to:
I've never seen the sense in URL rewriting. I reckon that's called "make a bookmark to I've also never seen the sense in bothering with SSL certificates. Seems to me that implies exposing the Pi to the Internet and I'd far rather do that with a VPN like WireGuard or ZeroTier. I'm explaining this so you understand that I'm approaching nginx from the viewpoint of someone who does not understand it, does not see the need for it, and who suspects that the reason why PR174 (gcgarner) and PR21 (SensorsIot) stalled is because my uninformed viewpoint is also the majority viewpoint. I keep hoping someone will explain why nginx is a good thing and why everyone should use it. I did actually try to get nginx running at one point because I was intrigued. I gave up. The main reason was because of the need to futz with every single container I wanted to associate with nginx. I thought that was a Very Bad Idea. At the time I thought the most likely explanation why I failed to make progress was that I had headed in the wrong direction. I assumed that someone who knew more about nginx (which could be you) would be able to get a lot further. In other words, I like to try to keep an open mind. So, please hear everything I'm saying as me still keeping an open mind. I'm going to try to help. My expertise, such as it is, is in IOTstack generally, not nginx, so IOTstack is my focus. Also, what follows is going to sound like a long list of complaints. Please don't hear it that way. I've been working through what you've done and I've written down the things I've noticed along the way. Yes, it's a long post and a huge brain-dump. Sorry. Can't be helped. To be perfectly honest, I think the best course of action is to withdraw this PR and start over. The main reason I say that is because I suspect (I don't know) that you have prepared your PR using a working clone of IOTstack. By "working", I mean a clone that is actually in use running your containers. I'm also guessing that you are not running IOTstack on a "real" Raspberry Pi. The reason I have those suspicions is because your PR includes commenting-out Raspberry Pi devices (ttyAMA0, vsio, gpiomem) in both the Home Assistant and Node-RED containers. That kind of change is going to break an awful lot of "real" Raspberry Pi implementations. Basically, you can't do that! In the influxdb and tasmoadmin service definition, it looks to me like conflict resolution markers have become part of your commit. Those will create a bit of a mess too. Also in the influxdb service definition, you seem to have removed Plus, the influxdb service definition has an In my opinion, it is a really really bad idea to confuse what you want (your specific configuration) with what is appropriate for everyone (the "factory" configuration). Once you have a configuration working on your system, you need to take a step back and ask how that abstracts to something that can be made part of the factory configuration. And the best way to do that is with a clean clone of IOTstack that you add things into by copying from your working system. You might find it helpful to read Preparing a Pull Request for IOTstack. Git has many different ways to skin every cat so I'm not going to say that that gist is the only or best way to go about creating pull requests, just that it might give you some things to think about. Now, let's rule a line under that. If I was attacking this problem (nginx) and I reached the conclusion that three containers were needed, I'd make them a single service definition. Something like this:
A couple of things I'll draw out:
I tried to spin-up that configuration on a Raspberry Pi running 64-bit Bullseye. There were two complaints from docker-compose:
A couple of observations:
Although
I have no idea what the "container ID" error is moaning about. The "unable to parse" is traceable to:
When docker-compose first instantiates a container, it runs down the list of volumes. For each path on the left hand side, docker-compose sees if that exists (file or directory). If it doesn't exist then it always creates the left-hand-side as a directory with root ownership. I see you've also added a That issue also explains the "solution" to this class of problem, which is to use a Dockerfile. If
In other words, a directory rather than a file. The Dockerfile copies the default I have not checked the ajoubert/docker-gen-arm image to see if any of this is feasible - mainly because the first thing to sort out is whether that's the appropriate image. If I'll emphasise that Issue 331 is 18 months old. It gives you the rationale for using Dockerfiles but the current Mosquitto and Node-RED implementations have moved on - there's now more control in the compose file when it comes to pinning versions etc. So that's current best practice. The last thing I'll say on this topic is that you need do everything three times, once for "new menu" (master branch), again for "old menu" (old-menu branch), and again for "experimental menu" (experimental branch). With old menu, the service definitions are indented by two spaces (just as they appear in the compose file), whereas new and experimental menus are left-aligned (the menu re-adds the spaces as it generates the compose file). New menu finds service definitions as soon as you put them in .templates whereas old-menu needs two extra lines of code to be added to
There may be other ways of doing this using Git/GitHub but I submit PRs in threes: one for each branch. Seems to work. While I think of it, I try to avoid including comment lines in service definitions. At one point those created problems with merging (when the menu uses yaml APIs to merge templates into the compose file). I don't know if that's still true but I don't want to find out "the hard way". That's why I removed all the comments from your service definitions before I tested them. I said I'd done some brief fiddling about with nginx before giving up. At the time I formed the impression that "labels" were what drove the show. So I don't understand how something like this works:
That's sending Which leads me to ask another question. As I read that, it's matching on URLs of the form "nodered{.subdomain …}.xip.io" - yes? Isn't that a bit specific? I mean, it's specific to you, isn't it? How will other people get on with different domains? So I suppose my final observation is that adding nginx to IOTstack might be best approached as:
|
nginx is its own beast. Another issue when rewriting URLs is that many applications don't like it when you rewrite URLs or pass HTTP through proxies. You often are required to add header rules and set specific things for specific applications. Some applications will not work at all ( Lissy93/dashy#1036 ) and need the developer to fix. I do use nginx on Kubernetes, but I run it with Authelia. That basically allows me to protect my stuff behind 2 factor auth. My mother in law can view the webcams I have setup so she can see her garden and stuff while out, we can keep an eye on the animals and that too. I can see if the furnace is running (or even turn it on and off remotely thanks to NodeRed). You're right when you say it can be achieved with a VPN as well, but I'm more comfortable with 2 factor. Apache is another alternative to nginx. nginx should have (editable) templates setup so the end user doesn't have to figure out all the correct http headers an application needs to run. Things like Grafana only require one or 2. Other ones like PiHole are a whole rabbit hole of issues when set behind nginx and requires documentation. I can also see git tokens (such as |
Please see PR #648 - I needed to make some changes to the template service definition for PiHole and I took the opportunity to re-align some things. Apologies if this causes any conflicts with your changes to the same file. |
No description provided.