taters
Instance: piefed.social
Joined: 3 months ago
Posts: 4
Comments: 19
None
Instance: piefed.social
Joined: 3 months ago
Posts: 4
Comments: 19
...Continued from PieFed Instructions...
~/pyfedi/.env.dockerfile. Look at~/pyfedi/env.sampleand add the other variables to~/pyfedi/.env.dockeraccording to your needs.nano ~/pyfedi/env.samplenano ~/pyfedi/.env.dockerdocker compose down && docker compose up -dUpdating PieFed Docker Container
docker compose downgit pulldocker compose up --builddocker compose down && docker compose up -dBackup/Restore Setup
I decided to keep it simple and use the
rsynccommand which comes already installed on Raspberry Pi OS. The guide linked below does a good job of explainingrsyncin a step by step process.Below the linked guide I'll provide an example of the commands I use to Backup and Restore my raspberry Pi. This creates a copy of the /rootfs folders that make up your Raspberry Pi Operating System and User folders. The commands will exclude some folders that may cause issues when restoring a backup. The guide linked below has more details.
Since I am going to power down the Pi and physically connect it's hard drive to my computer, I don't have to worry about making backups on a live and running storage.
The below commands assume I also have an additional EXTERNAL_STORAGE hard drive connected to my computer. This means the backup command will copy the contents from the Raspberry Pi drive (/rootfs folder) to the EXTERNAL_STORAGE drive (/EXTERNAL_STORAGE/backup folder). The restore command will copy the contents from the EXTERNAL_STORAGE drive (/EXTERNAL_STORAGE/backup/rootfs folder) to the Raspberry Pi drive (/rootfs folder)
rsyncWILL delete data on the target location to sync all files and folders from the source location. Be mindful of which direction you are going to avoid any losses. I suggest testing it out on some other folders before commiting to backing up and restoring the entire Raspberry Pi. The guide linked below also covers exclusions to minimize backup sizes.The backup storage MUST be formatted in EXT4 to make sure file permissions and attributes remain the same.
alias rsyncBACKUP="sudo rsync -avxhP --delete --exclude={'proc/','sys/','dev/','tmp/','run/','mnt/','media/','home/USERNAME/.cache','lost+found'} /media/USERNAME/rootfs /media/USERNAME/EXTERNAL_STORAGE/backup/"rsyncRESTORE="sudo rsync -avxhP --delete --exclude={'proc/','sys/','dev/','tmp/','run/','mnt/','media/','home/USERNAME/.cache','lost+found'} /media/USERNAME/EXTERNAL_STORAGE/backup/rootfs/ /media/USERNAME/rootfs". ~/.bashrcrsBACKUPrsRESTOREFirewall (LOCAL HOST)
sudo apt install -y ufwsudo apt install -y gufwI haven't figured out how to properly set this up for myself yet, but I figure it's probably worth having for an additional layer of protection.
...Continued from PieFed Instructions...
Cloudflare Website Settings
These settings are suggested to help manage traffic. See here for more detailed information.
Create Rule-> Change the following settings and values on Cloudflare to match what's listed below:Allow Inbox/inboxCreate rule-> Change the following settings on Cloudflare to match what's listed below:ActivityPub/activities/Or/activities//api//nodeinfo//.well-known/webfinger+ add settingIgnore cache-control header and use this TTLDeployto completeCreate ruleagainActivityPub2application/activity+jsonOrapplication/activity+jsonapplication/ld+json+ add settingIgnore cache-control header and use this TTL10 secondsDeployto complete.env.dockerFileCreate Token-> ClickGet Startedunder Create Custom TokenPieFedContinue to summary-> ClickCreate Tokennano ~/pyfedi/.env.dockerCLOUDFLARE_API_TOKEN = 'ZONE.CACHE_PURGE_TOKEN'CLOUDFLARE_ZONE_ID = 'API_ZONE_ID_TOKEN'docker compose down && docker compose up -dTroubleshooting
USERNAMEwith your username.cd ~/pyfedisudo chown -R USERNAME:USERNAME ./mediaLemmy (LOCAL HOST)
The lemmy instructions are simple and straight forward. When changing the fields asked of you in the instructions, it's helpful to search and replace the required fields. In
nanowhen editing a file, pressCTRL + \and follow the instructions at the bottom of the window. This will find and replace text.The Lemmy instructions show text for editing with
{{ Example }}. To avoid confusion, those curly braces must be removed and replaced with the expected data.81to10633Test federation, replace capitals with the required information
curl -H 'Accept: application/activity+json' https://DOMAINNAME.COM/u/LEMMY_USERNAMEUpdating Lemmy Docker Container
See here for more information.
docker compose downdocker compose pulldocker compose up -dPieFed (LOCAL HOST)
The PieFed installation instructions will provide more detailed information about each step. This guide does NOT cover any email setup for PieFed.
If you used NPM's login page to test Cloudflare Tunnels, you will need to login to NPM and change the Port Forward from
81to8030PieFed Install Instructions
git clone https://codeberg.org/rimu/pyfedi.gitcd pyfedicp env.docker.sample .env.dockernano .env.dockernano compose.yaml8030:5000. You can change the external container port:8030:if you are using a custom port. Do NOT touch the internal container port:5000.ports:- '8030:5000'export DOCKER_BUILDKIT=1sudo docker compose up --builddatabase system is ready to accept connectionsin your terminal window after PieFed is done installing and loading. This means you are ready to attempt a connection through your Web Browser now.cd ~/pyfedichown -R USERNAME:USERNAME ./pgdatasudo docker exec -it piefed_app1 shexport FLASK_APP=pyfedi.pyflask init-dbexitCTRL + Cto stop PieFed.docker-compose up -dUSERNAMEto your username.sudo nano /etc/cron.d/piefedCloudflared (LOCAL HOST)
!!Only proceed with these instructions after setting Cloudflare as your Primary DNS provider. This process may take up to a day after changing nameservers!!
The following instructions do a few things. First you will install
Cloudflared(with a 'd'). Then you will be asked to log in, create a tunnel, run a tunnel and then creating a service (while the current tunnel is running) so your tunnel can run automatically from startup.I've noted that this will be installed on the local host (where you are hosting an instance), we will be installing
Cloudflaredon multiple devices for reasons I will cover later. Hopefully this reduces confusion later on.credentials-file: /root/.cloudflared/<Tunnel-UUID>.json->credentials-file: /home/USERNAME/.cloudflared/<Tunnel-UUID>.jsonCTRL + Cto exit this tunnelRun as a service
sudo cp ~/.cloudflared/config.yml /etc/cloudflared/config.ymlcloudflared service installsystemctl start cloudflaredsystemctl status cloudflaredCTRL + Cwhen done to exitEnable SSL connections on Cloudflare site
If you used NPM as a reverse proxy and it's set to port 81, go to any Web Browser and type in your DOMAINNAME.COM. You should be directed to NPM's login page. Check the address bar and your domain name should have a padlock symbol followed by https://DOMAINNAME.COM. Note that it should read HTTPS:// (with an s) and not HTTP:// (without an s). HTTPS along with the padlock symbol means your connections are properly encrypted.
This is the most complicated step for self-hosting. If you can confirm your connection is encrypt, setting up other services and webapps are fairly straight forward.
Port Forwarding/Reverse Proxy
Port Forwarding
Pick a port number between 1024-65,535. This is how Cloudflare will send data and remote connections to your instance without worrying about blocked ports. I like to use 5050 because it's simple, easy to remember and not used by any of my other self-hosted services. To be consistent, for the rest of this guide I will use port 5050 as an example. Feel free to replace it with any port number you feel like using.
Router settings are different for each device, refer to a manual or call your ISP for support depending on your situation.
hostname -ITCPconnections on port5050.InternalandExternalfields, simply add5050to both fields.If you are only hosting a Lemmy or PieFed instance, you will be able to do that without the need of a Reverse Proxy which is described below. In this case you can simply use the default ports for Lemmy or PieFed. Replace my example port
5050with the following depending on your needs:106338030Reverse Proxy
A reverse proxy allows the local host machine to distribute incoming user connections to different services hosted on the local machine. For example, all data from Cloudflare comes in on port
5050when accessing the DOMAINNAME.COM address. I can use Subdomains to redirect incoming connections on port5050to open ports on my local host machine.For example, both Lemmy and PieFed can be hosted at the same time. We can use the subdomains lemmy. and piefed. to redirect traffic. When a user types lemmy.DOMAINNAME.COM into the address bar, Cloudflare will send the connection through
5050to your home and private router which then continues to the Reverse Proxy. The Reverse Proxy running on the local host machine will catch the subdomain request and immediately switch to port10633where a connection to Lemmy will be completed. Typing in piefed.DOMAINNAME.COM will guide all requests to port8030where PieFed is running and complete that connection.For simplicity, Nginx Proxy Manager is docker based with an easy to use web user interface that's accessible through your local network connected Web Browser. It has it's limitations but works fine for the current needs.
Nginx Proxy Manager (LOCAL HOST)
NPM is extremely simple to set up. Simply create a new folder, create a docker-compose.yml file filled with the necessary information and then run the container.
mkdir ~/npmcd ~/npmnano docker-compose.ymlNote that port
5050:externally connects to NPM internally through port:80. Make sure5050matches the Cloudflare Tunnel port you have decided on using.docker compose up -dand wait for the services to start running:81into the address bar. For example192.168.0.100:81. See Port Fowarding for help finding your local IP address.81to test Cloudflare Tunnels before installing Lemmy or PieFed. This is the login page for NPM. This can be quickly changed to the ports listed below after confirming a secure connection from Cloudflare Tunnels.106338030Requirements
Setup & Software Installation (LOCAL HOST)
The required software to host Lemmy or PieFed will include
Additional software I will also cover but aren't necessary are:
Docker (LOCAL HOST)
The official Docker instructions are clear, quick and simple. The process will also add their repository information for quick and easy updates. This will be installed as a service on your operating system.
I was able to generate a Zone.Cache Purge token for CLOUDFLARE_API_TOKEN similar to your screenshot.
The INSTALL.md says "CLOUDFLARE_ZONE_ID - this can be found in the right hand column of your Cloudflare dashboard in the API section." and I'm not sure where to find this or maybe what I'm looking for.
That worked perfectly, thank you :)
I've tried just building PieFed in docker with as few things changed as possible and I am still running getting the same message when I try to log in. The CSRF tokens do not match.
The only change I made was in the .env.docker file which was SERVER_NAME='pi.DOMAINNAME.ca:8030'
This is what the reverse proxy in nginx looks like now:
I've tried changing ports, commenting out different parts and it's still the same. I've even checked the port forwarding settings and I still getting the same message. I did notice when I ran
netstat -tunplI didn't see any ports from docker for port 5000. If I understand how the reverse proxy works, I should have a connection coming in from the outside on port 8030 and be redirected by nginx to port 5000 on the local machine where PieFed is hosted? If that's right, then nginx isn't sending anything through 5000 locally and just through 8030 I think.No worries, I'm at least learning a lot about network communication and using the terminal in linux more comfortably. In this case I learned how virtual environments work.
Also since it's a Pi, I've been copying and swapping SD cards at certain points as a backup. It's easy to clean up learning mistakes along the way. It's also good practice before I do it all over again on a proper storage device.
There is just one PieFed running in docker on the Pi. My labeling might be a little confusing there.
I followed the easy instructions up until getting PieFed running in the background then skipped down to the Running PieFed in production section. I didn't see any of the files mentioned in that section and thought to continue from there.
To start, if I load PieFed first, then nginx I get an error like below:
nginx error:
If I do the opposite and load nginx before PieFed, PieFed will make a similar complaint about sharing the same port.
The pyfedi.service, celery.service and celeryd files all look similar to the examples from the INSTALL.md except I changed the directory names to match my name in the appropriate places.
Here are the error messages I am getting from systemctl:
pyfedi.service error/celery.service error:
At this point I am stuck and not sure where to go from here.
You're right, it was outdated. It seems I got mixed up after a fresh OS install on my Pi. I used APT to download and install docker which is extremely outdated. I now have proper repositories set up for both docker and nginx and everything is up to date. I didn't need to make any changes to the dockerfile with the proper version.
I'm having issues getting nginx, pyfedi.service and celery.service to work.
Below are some snippets from my notes which should lay out all the steps I've taken, hopefully that will explain where I am currently at.
Steps from fresh OS Install:
/etc/nginx/sites-enabled/DOMAIN file:
I decided to start over today with a fresh OS install on my Pi. I did everything according to a checklist I started so nothing new has changed from my knowledge. I am getting errors trying to get past the
part of the INSTALL.md for the docker instructions.
I've saved a copy of my terminal but I'm not sure where a good spot to paste it is since it's long. There were a lot of permission error 13's so I tried
and things started to download and proceed up until a point before another error showed up.
I'm quite confident I did nothing different this time so I don't know what would be causing issues today. I can provide you with the outputs from my terminal if that will help you.
Yeah, I had :5000 at the end, otherwise I would have gotten an error with the initial website connection from a browser saying the domain did not match. That's how I figured out to change the port in the compose.yaml from an earlier attempt.
I did not create a reverse proxy. I got excited at getting the site to load that I missed that. I'll try that in a couple days when I'm free again.
Docker decided to randomly disappear my PieFed image an hour after I finished working on it. The PyFedi folder and all it's contents have vanished. A very quick search showed that it has happened to other people with other images. So it's a thing maybe? Strange but fortunately it was all fresh and nothing was lost.
So after a few attempts, I was able to get PieFed working by accessing it through pi.MyDomainName.ca:5000
I changed the SERVER_NAME in .env.docker to match the address above, but with my actual domain name. I also changed the port numbers from 8030:5000 to 5000:5000 in the compose.yaml
I am running into an issue when I attempt to use the login information after the database initialization steps. I get the error "The CSRF tokens do not match." above the username field on the login screen. I'm not sure what that means exactly.
Other than that, using the docker was fairly straight forward except for some information I forgot to put in correctly the first couple times.
Thanks for the suggestions, I'll have a look into them and see how they fit my needs. I am looking for something that uses markdown language. I'm using that in other parts of this project as a way to keep things unified and simple for others to participate or contribute.
I don't do blogs or anything but I do intend to make a community on slrpnk.net in addition to my local instance on my pi. The Solarpunk community will focus more on creating a guide for others to create their own local communities and knowledge base.
The ultimate goal is making sure it's simple and accessible to as many people as possible.
Once I set up an instance or some sort of community page, I plan to write up an outline of decision choices and future goals in order to help people understand what's going on and where to begin contributing. I'll be able to use my seed library as a working example.
I am hoping to be ready within the next couple weeks. I can let you know when the Solarpunk community goes up so you can check it out.
Thanks for the information.
I have a more questions about account registration/logins. If I understand correctly, they will require SSL.
Before I ask anything, I just want to explain what it is I want to do so it's easier to understand where I'm coming from.
I want to start a seed library for my local community in my town. Unless Monsanto is targeting libraries for heritage seeds, I feel my risk is quite low.
I would like a simple place for people to talk, share information and organize events. I'm also trying to create everything as independent from outside services as possible. The reason being that if any of these outside services experience an extended outage, I can physically move my Raspberry Pi box to central location with local internet/wifi (a library for example) and people will still be able to access all the information. Think of the pi box as becoming a digital community board. In this situation, federation is completely unimportant.
If Cloudflare tunneling experiences issues or outages, can people still create and login to accounts locally? I'm going to assume any disruptions to any email services would also have an effect since that is used for registration as well.
I prefer the Reddit/Lemmy/Piefed style and the markdown language works well with the other parts of my project. It's not necessary and I may keep searching around for something that suites my use case better.
I'll most likely go ahead and try installing PieFed anyways with Cloudflare tunneling(or Let's Encrypt if I don't have to worry about blocked ports) and smtp2go. At the very least it'll be an experience and a good place to start for my needs. I can move on from there if I feel the need to.
Thanks again.