Skip to content

Instantly share code, notes, and snippets.

@WreckingBANG
Last active July 16, 2024 19:26
Show Gist options
  • Save WreckingBANG/405235949c655cd8246188ba25c42277 to your computer and use it in GitHub Desktop.
Save WreckingBANG/405235949c655cd8246188ba25c42277 to your computer and use it in GitHub Desktop.
How to locally Host Piped with Subscription Feed

How to locally Host Piped with Subscription Feed.

I did not find any clear Guide on how to do it, so I thought I would just create one.

The Goal:

  • A completely local Piped Server without Port Forwarding
  • A working Subscription Feed

The Things you need:

  • A Machine you want to run your Piped Server on (I will be using Debian 12)
  • Nginx Proxy Manager (If you don't have it, I can recommend this guide: https://piped.video/watch?v=qlcVx-k-02E)
  • A Domain (you don't need to own one, you can add a DNS-Entry, but I would recommend one)
  1. Install Docker and Docker Compose:

    sudo apt install docker docker-compose -y
    
  2. Then you need to clone the Piped Docker GitHub Repository and cd into it:

    git clone https://github.com/TeamPiped/Piped-Docker && cd Piped-Docker
    
  3. After that, you need to execute the installation Script:

    ./configure-instance.sh
    
  4. Now you will be asked a few Questions:

    Enter a hostname for the Frontend (eg: piped.kavin.rocks):
    piped.yourdomain.tld
    
    Enter a hostname for the Backend (eg: pipedapi.kavin.rocks):
    pipedapi.yourdomain.tld
    
    Enter a hostname for the Proxy (eg: pipedproxy.kavin.rocks):
    pipedproxy.yourdomain.tld
    
    Enter the reverse proxy you would like to use (either caddy or nginx):
    nginx
    
  5. After that, go to your already-setup Nginx Proxy Manager (can also be on a different Computer)

    In there, you will need to Set up a new Proxy Host: image

  6. If you want, you can select your SSL Certificate under the SSL tab.

  7. And on the Advanced Tab, you need to insert this line:

    proxy_set_header Host $host;
    
  8. Now you can save this and head back to your Piped Server.

  9. After all that, it is finally time to start your Server. Keep in mind that you still need to be in the ~/Piped-Docker Directory. You can start your instance by executing:

    docker-compose up -d
    
  10. Now you should be able to head to your URL and access Piped.

The Subscription Feed Problem:

You will notice that the Subscription Feed is never refreshing. That is a limitation that Piped currently has. You would need to expose the API to the Internet, which you probably don't want.
You could use something like Cloudflare Tunnel, but then it is not truly local anymore.

Thankfully, like in the Issue TeamPiped/Piped#707 described, someone found a good solution to that. It is not perfect, and you should only use it if you do not subscribe to many people, or you could get rate-limited.

It is a small script that reads the Subscribed Channels from the Database and curls everyone.
This Script is by: https://github.com/vayan and is from TeamPiped/Piped#707

To use it, do the following steps:

  1. Create a new file:

    nano ~/Piped-Docker/refreshsubscriptions.sh
    
  2. Paste this and change the pipedapi.yourdomain.tld to your actual domain:

    #!/bin/bash
    
    subscriptions=$(docker exec -i postgres psql -U piped -d piped -qtAX -c 'select id from public.pubsub;')
    
    while IFS= read -r line; do
            curl -k "https://pipedapi.yourdomain.tld/channel/$line" > /dev/null
            sleep 1; 
    done <<< $subscriptions
    
  3. Open Crontab:

    crontab -e
    
  4. Enter the following line at the bottom; the number at the front is the hours. In this example, it gets executed every 3 hours. You can adjust it to your needs.

    0 */3 * * * /home/username/Piped-Docker/refreshsubscriptions.sh >/dev/null 2>&1
    
  5. Now your setup is finished.

@adolky
Copy link

adolky commented Jul 15, 2024

do you use libretube app on android? i have not been able to make it work when i change to my private instance i configured my private server following your procedure, i check the logs and there is no error. the video load but dont play.

@WreckingBANG
Copy link
Author

WreckingBANG commented Jul 16, 2024

@adolky

do you use libretube app on android? i have not been able to make it work when i change to my private instance i configured my private server following your procedure, i check the logs and there is no error. the video load but dont play.

Yes i do. I need more informarion. Do you use nginx-proxy-manager? Did you configure the custom instance like this?
Example

Edit: You might also need to enable "use HLS" and "LBRY HLS" under Video and Audio in the Setting because of Dash Issues.

Please let me know if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment