Skip to content
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

Make sure ports are randomized #3

Closed
dessalines opened this issue Oct 14, 2021 · 5 comments
Closed

Make sure ports are randomized #3

dessalines opened this issue Oct 14, 2021 · 5 comments

Comments

@dessalines
Copy link
Member

Otherwise multiple lemmy's can't run on the same machine.

@Nutomic Nutomic closed this as completed in 5c195b7 Nov 9, 2021
Nutomic added a commit that referenced this issue Nov 9, 2021
@rysiekpl
Copy link

This is... not the right way to deal with this issue, for several reasons:

  1. Randomizing ports means you might end you with the same port used for different services. The more services you are running, the higher the likelihood of that. What if other services are running on the same host, not just Lemmy-related?

  2. It makes debugging any issues much more difficult. The necessity of figuring out which service runs on which port alone adds substantial additional mental strain.

Taken together, this will cause difficult-to-debug issues, including issues that this is trying to solve: different Lemmy instances trying to use the same port.

The right way of dealing with this would be:

  1. Include a minimal nginx config in the docker-compose setup. For small, single-instance Lemmy deployments, no additional nginx would be required, the nginx ports 80/tcp and 443/tcp could be exposed directly to the Internet. The letsencrypt set-up could be deployed within the docker-compose set-up, this limiting any side-effects on the host system, making the a Lemmy deployment nicely self-contained (much like postfix is used currently).

  2. If multiple instances of Lemmy are to be deployed on a single host, you only need to make the port 80/tcp available from the nginx container on localhost, to be then reverse-proxied by an nginx running on the host (as currently). Ask the admin to choose the target ports, or propose ports to them (80/tcp for the first one, 81/tcp for the second one, etc), but non-randomly. That way you can be sure that ports use does not overlap, and the admin has less of a hard time debugging things when stuff goes wrong.

@rysiekpl
Copy link

Alternatively, and even better, have the nginx that would be included in docker-compose config handle all Lemmy instances managed by this ansible playbook. In that case you don't care about the ports, since you can use named containers, like lemmy-exampe-com, lemmy-ui-example-com, etc., for example.com domain, and then lemmy-exampe-net, lemmy-ui-example-net, etc., for example.net domain, and so on.

Generate the docker-compose.yml file from a template looping over the domains.

@rysiekpl
Copy link

Port randomization also makes it more difficult to keep track of changes (for example, as backups, or as configuration in separate git repos) in host-deployed nginx config and the docker-compose.yml, as these effectively change with every deploy.

@dessalines
Copy link
Member Author

The chances of port conflicts on a large range of ports is small, but PRs welcome for a better way to do this.

@rysiekpl
Copy link

The chances of port conflicts on a large range of ports is small

Small, but non-zero, so the problem remains unfixed. It is worse, though, as now it is, well, random when problems arise. Making automation potentially fragile, and making debugging a potential issue more difficult.

but PRs welcome for a better way to do this.

Started a separate issue: #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants