fix: publish nginx on the configured ports - #1546
Open
geodro wants to merge 1 commit into
Open
Conversation
nginx.http_port and nginx.https_port were read by everything that talks to nginx, the share commands, the profiler probe, the watcher and the install-time port check, but never by the thing that actually binds. Both writers rendered the bundled quadlet template, which publishes 80:80 and 443:443, and nothing substituted the configured values, so on a host where another service owns those ports there was no supported way to move nginx off them. This is not the macOS-only fault it looked like from the plist. The launchd generator builds its -p arguments from the quadlet's PublishPort lines, so it was faithfully reproducing a template both platforms share. ApplyNginxPorts rewrites the host side of those mappings by matching the container port, leaving 80 and 443 inside the container where nginx listens, and runs before the loopback and IPv6 prefixes are added so it handles either form. A port left unset keeps the bundled default. Both writers call it, since having two of them is how this was missed in the first place, and config.NginxPorts is now the single place the two numbers come from. Doctor's port section was the visible half of the same problem. It probed the literal 80 and 443, and when nginx was up it reported them as fine without probing at all, so a host with nginx demonstrably on 10080 was told about port 80 either way. It now reports and probes whatever is configured.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nginx.http_port and nginx.https_port were honoured by everything that talks to nginx, the share commands, the profiler probe, the watcher, the install-time port check, but never by the thing that actually binds. Both writers rendered the bundled quadlet template, which publishes 80:80 and 443:443, and nothing substituted the configured values. On a host where another service owns those ports there was no supported way to move nginx off them.
Worth flagging for the report: this is not macOS-only. The launchd generator builds its -p arguments from the quadlet's PublishPort lines, so the plist was faithfully reproducing a template both platforms share, and a Linux install should have been just as broken.
ApplyNginxPorts rewrites the host side of those mappings by matching the container port, so 80 and 443 stay inside the container where nginx listens and only the host side moves. It runs before the loopback and IPv6 prefixes are added, so it handles either form, and a port left unset keeps the bundled default. Both writers call it, since having two of them is how this was missed, and config.NginxPorts is now the single place the two numbers come from.
Doctor's port section was the visible half of the same problem. It probed the literal 80 and 443, and when nginx was up it reported them fine without probing anything, so a host with nginx demonstrably on 10080 was told about port 80 either way. It now reports and probes whatever is configured.
Refs #1544