I have tried the docker, ansible, and scratch methods. I have been troubleshooting for a month now. I have gotten nowhere. I need someone to help walk me through how to deploy a lemmy server because the guides are absolute trash.
Please help. I’m wasting money running this VPS and for literally nothing.
Edit: So, I’ve tried the ansible method, but I can’t access my server this way. It just keeps saying “UNREACHABLE”. I have generated a dozen keys, none of them work. I have NO PROBLEMS with ssh in Putty. I can use Putty all day. Putty works fine using my ssh key. Ansible does not. No amount of new keys has made any difference. I have countless keys in my stupid droplet because of this hacky garbage.
Could you tell us what has failed / did not work on your previous attempts? Also, what setup did you use, what reverse proxy you had in front of Lemmy if any, etc.
Okay, so it looks like nginx is a reverse proxy. That is the step I was on. It doesn’t work. Last thing I did was to modify the docker-compose.yml file and change the port from 80 to 1236. I was told to do that by someone who has been trying to troubleshoot with me for 2 weeks now. It doesn’t say to do that anywhere, but they told me to so I did. Then they said to “add this to my upstream” but I haven’t a fucking clue what that means so I don’t know what to do next. There is a config file in etc/nginx/sites-enabled/nginx.conf that the guide directed me to edit. This is the guide that I was directed to use to set up nginx. I was on the step where it requests the nginx status and mine just says “inactive”. I promise, I am following these guides PRECISELY. I don’t know what I am doing wrong, but all the solutions that I have received are things that the guide DOES NOT say to do. So I don’t know where I am. I am happy to start fresh. You just let me know.
In my opinion its best not to touch the nginx that’s set up by Lemmy and it’s better to have another reverse-proxy in front of it.
I’ll try to come up with an solution later in the day, gotta do my daily at work.
No problem at all. Thanks for getting back to me. I really do appreciate it!!! I have a busy day today too but I’ll try to be vigilant about responding.
So, here’s something that might work. I tested it on my local machine, up to Caddy but without HTTPS, but I’m confident it’ll work once deployed on a server.
Prerequisites:
Setup
First, create a folder and download the following files:
nginx.conf
Then, generate passwords for PostgreSQL and your admin user, store them somewhere safe.
Config changes
lemmy.hjson
You’ll want to change the
admin_username
,admin_password
andsite_name
to match your primary user’s credentials and the name you want to give your instance.Then, change
hostname
to match your domain name: if it issub.domain.tld
then it should readhostname: "sub.domain.tld"
.The base config file does not have proper configuration for the database, so you’ll have to edit the
database
field as follows with the password you previously created:database: { host: postgres database: "lemmy" user: "lemmy" password: "POSTGRES_PWD" # Change for your password }
Additionally, if you want to send emails for registration confirmation and password resets, add the following before the closing
}
and change to match your email provider configuration.email: { # Hostname and port of the smtp server smtp_server: "SMTP_SERVER" # Login name for smtp server smtp_login: "SMTP_LOGIN" # Password to login to the smtp server smtp_password: "SMTP_PASSWORD" # Address to send emails from, eg "noreply@your-instance.com" smtp_from_address: "SMTP_LOGIN" # Whether or not smtp connections should use tls. Can be none, tls, or starttls tls_type: "starttls" }
docker-compose.yml
By default the compose file is meant to build a development version of Lemmy, we will change this by removing the blocks with
build
and uncomment those withimage
. Note: think to update the images to0.18.2
since it fixes some vulnerabilities.Also, since we will use a reverse proxy and I don’t now if your server has a firewall, we should remove the
ports
blocks which are used to expose the services’ ports on the host.Finally, make sure to change the
POSTGRES_PASSWORD
field to match the PostgreSQL password you set inlemmy.hjson
.It should look something like that:
Reverse-proxy
For the final touch, we are going to setup Caddy, a reverse proxy with HTTPS support out of the box. You could use pretty much any reverse proxy you want, but I chose Caddy for its easy setup.
First, create a file nammed
Caddyfile
and write the following in it:Make sure to match your actual domain name.
Finally, update the
docker-compose.yml
file to add the following at the end (make sure that it’s correctly tabulated)Launching the instance
Before starting the stack, we have a few things left to do:
mkdir -p volumes/postgres volumes/pictrs
volumes/pictrs
:sudo chown -R 991:991 pictrs
Finally, to start everything:
docker compose up -d
So, here’s something that might work. I tested it on my local machine, up to Caddy but without HTTPS, but I’m confident it’ll work once deployed on a server.
Prerequisites:
Setup
First, create a folder and download the following files:
nginx.conf
Then, generate passwords for PostgreSQL and your admin user, store them somewhere safe.
Config changes
lemmy.hjson
You’ll want to change the
admin_username
,admin_password
andsite_name
to match your primary user’s credentials and the name you want to give your instance.Then, change
hostname
to match your domain name: if it issub.domain.tld
then it should readhostname: "sub.domain.tld"
.The base config file does not have proper configuration for the database, so you’ll have to edit the
database
field as follows with the password you previously created:database: { host: postgres database: "lemmy" user: "lemmy" password: "POSTGRES_PWD" # Change for your password }
Additionally, if you want to send emails for registration confirmation and password resets, add the following before the closing
}
and change to match your email provider configuration.email: { # Hostname and port of the smtp server smtp_server: "SMTP_SERVER" # Login name for smtp server smtp_login: "SMTP_LOGIN" # Password to login to the smtp server smtp_password: "SMTP_PASSWORD" # Address to send emails from, eg "noreply@your-instance.com" smtp_from_address: "SMTP_LOGIN" # Whether or not smtp connections should use tls. Can be none, tls, or starttls tls_type: "starttls" }
docker-compose.yml
By default the compose file is meant to build a development version of Lemmy, we will change this by removing the blocks with
build
and uncomment those withimage
. Note: think to update the images to0.18.2
since it fixes some vulnerabilities.Also, since we will use a reverse proxy and I don’t now if your server has a firewall, we should remove the
ports
blocks which are used to expose the services’ ports on the host.Finally, make sure to change the
POSTGRES_PASSWORD
field to match the PostgreSQL password you set inlemmy.hjson
.It should look something like that:
Reverse-proxy
For the final touch, we are going to setup Caddy, a reverse proxy with HTTPS support out of the box. You could use pretty much any reverse proxy you want, but I chose Caddy for its easy setup.
First, create a file nammed
Caddyfile
and write the following in it:Make sure to match your actual domain name.
Finally, update the
docker-compose.yml
file to add the following at the end (make sure that it’s correctly tabulated)Launching the instance
Before starting the stack, we have a few things left to do:
mkdir -p volumes/postgres volumes/pictrs
volumes/pictrs
:sudo chown -R 991:991 pictrs
Finally, to start everything:
docker compose up -d
Weird, my comment does not seem to be picked up by lemmy.world, even after deleting and re-submitting it 🤔
https://lemmy.blackeco.com/comment/150520
It doesn’t tell you to actually run nginx, it assumes it will automatically run when installed. I don’t know why, that sounds like dumb behaviour even if it were correct. You are right about the guides being trash.
I recommend getting used to package manager (apt, dpkg) and system daemon/init system (systemd - accessed via systemctl) and then ignoring that guide. Installing and running nginx isn’t complex enough to warrant a guide; installing packages and running services, in general, are just. Configuring nginx, however… If you know the concepts, it’s pretty easy. The concepts are hard.
That may be so, but the link that they give references a digital ocean guide that DOES (it’s literally step 2). So, am I just ignoring that part? How do I figure out which parts of a guide should be followed and which ones shouldn’t?
I haven’t gotten it to work yet so I disagree.
Okay, I keep getting this question re: “reverse proxys”, but I’m having trouble answering this because the guide does not use that language. There are no steps that direct me to edit, add, modify a “reverse proxy”. So if there is a step in the guide that you know to be a “reverse proxy” then please tell me what it is. I am following the guides EXACTLY. There are a lot of missing steps, but most of these are things that were implied by the guide and not explicitly stated.
I have tried the docker method. I have gotten close with this, as in, I can use the IP to access the instance, but I have not been able to get the domain to work. My A record is set up correctly. I used lemmy-easy-deploy to get it working the first time and it DID, but that dev does not support instances made for actual deployment so many features just don’t work. It’s not feasible at all. But my domain DID work. So I know my A record is set up correctly.
I have tried the scratch method. That was a nightmare and nothing worked as expected. I am more than happy to try if you are willing to help me negotiate it.
I have tried the ansible method. My local PC will not connect to the server with ansible. I have created a dozen new keys and NONE of them work. Ansible WILL NOT CONNECT. I have been using Putty to access the server and it works flawlessly, all day, every day. So I obviously have a working key. Ansible is not working. It just keeps saying “UNREACHABLE”. I have googled this and found no solution that even remotely addressed what I am trying to do.
I don’t know what to do so you tell me and I’ll fucking do it. Would you like me to start with the docker method? Would you like me to try the ansible method? Would you like me to try the scratch method? You tell me. I don’t know. I don’t care. I just want to get it working.
There are 2 reverse proxies involved. One is Nginx which is used to front both the Lemmy UI and the Lemmy backend. That’s what the ‘proxy’ container in the docker compose file is for. It seems to be a required component of the application stack as different request types to the same host FQDN are sent to different backends (‘upstreams’ in network speak). You could use Caddy here instead if you wanted, which is the point of this page: https://join-lemmy.org/docs/administration/caddy.html. However, that config doesn’t work for the latest version of Caddy (you’ll get an error about stuff being outside of the site block).
The other one (could either be Nginx again or Caddy or anything else you want instead) is to front the whole thing and provide TLS termination using Letsencrypt. This bit is explained here: https://join-lemmy.org/docs/administration/install_docker.html#reverse-proxy--webserver
Is the server you’re trying to deploy in a local network? Have you setup your ISP router to route ports 80 and 443 to your server? Or are you using Cloudflare Tunnel?
As for reverse proxy, it’s usually Caddy or nginx-proxy to get a SSL certificate (for HTTPS) for your service.
I am using digital ocean.
I don’t know what that is. What is an ISP router? Is that a config file on my server? You really need to spell it out. I am following the guides. That is what I know. If you have a better guide that uses this verbiage then please send it. I am happy to learn.
And during the docker method, I was trying to set up nginx and the status is inactive. It will not start.
Here is the status message:
Look in /etc/nginx/nginx.conf, it probably
include
s ./sites-available/*.conf, look in there forssl_certificate
(_key
) that mentions that fullchain.pem, remove/comment(#
) and restart nginx. It may still bitch about not having a cert for ssl, in which case take that out of thelisten
directives too.ISP = Internet Service Provider, so your Telco provider. By ISP router I was meaning the box you use at home to connect to the Internet as I presumed you were self-hosting at home. But since you are on Digital Ocean this is irrelevant.
I’m not familiar with Digital Ocean, do you have access to a standard Linux box with SSH or are you using some sort of Web UI like cPanel to manage it?
Oh, so my router, 🤣 lol, my bad.
And yes, I use Putty to access the server currently. root@IP with an RSA key. It works perfectly on Putty. Ansible just will not connect. No idea what to do there. It just says “UNREACHABLE”. I have added and removed a dozen or so keys generated on the WSL Ubuntu Ansible local machine and none of them work.