Peertube - bad gateway 502 (fixed) but can't install plugin or theme

Hello. this is new installation on debian 11 with nginx and first time on peertube platform. Initially had working peertube but couldn’t access site outside of localhost until edited /config/production.yaml to (following this thread>

config/production.yaml
<
Listen:
hostname: ‹ 0.0.0.0 ›
port: 9000

Setting hostname to ‹ 0.0.0.0 › seemed to make the site accessible to web (fixed bad gateway 502 error), however i’m still not certain as to why nginx is configured to need it that way in my instance? Something to do with reverse ip resolution? However the site does seem to function primarily with it configured that way. I’m an amateur linux admin and a little more accustomed to apache. However relatively a novice with server administration in general.

Now when i attempt to install a plugin or theme i end up getting « Error cannot install peertube-theme-dark » in the admin>Plugins/themes options of the web interface. I’ve checked that peertube is the owner of /var/www/peertube recursively.

> #journalctl -feu peertube 
> Returns this info...
> ###
> Aug 23 17:20:21 modvid peertube[70052]: [modvid.com:443] 2024-08-23 17:20:21.398 error: Client log: Error: Cannot install plugin peertube-theme-dark {
> Aug 23 17:20:21 modvid peertube[70052]:   "username": "root",
> Aug 23 17:20:21 modvid peertube[70052]:   "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0",
> Aug 23 17:20:21 modvid peertube[70052]:   "url": "https://modvid.com/admin/plugins/search?pluginType=2"
> Aug 23 17:20:21 modvid peertube[70052]: }
> Aug 23 17:20:21 modvid peertube[70052]: [modvid.com:443] 2024-08-23 17:20:21.399 info: 192.168.0.0 - - [23/Aug/2024:22:20:21 +0000] "POST /api/v1/server/logs/client HTTP/1.0" 204 - "https://modvid.com/admin/plugins/search?pluginType=2" "Firefox"
> ###

Under Admin > System > Debug in the web interface i have this information as well.

> IP address
> 
> PeerTube thinks your web browser public IP is **127.0.0.1**.
> 
> If this is not your correct public IP, please consider fixing it because:
> 
> * Views may not be counted correctly (reduced compared to what they should be)
> * Anti brute force system could be overzealous
> * P2P system could not work correctly
> 
> To fix it:
> 
> * Check the `trust_proxy` configuration key
> * If you run PeerTube using Docker, check you run the `reverse-proxy` with `network_mode: "host"` (see [issue 1643](https://github.com/Chocobozzz/PeerTube/issues/1643#issuecomment-464789666))
> ####

sorry if thread is formatted poorly. Trying to avoid more than 2 hyperlinks as per new user rules
I hope i’ve provided enough information. Let me know if other logs would help. I appreciate any time and attention provided to find a solution.
Sincerely,
Darcy

Are you able to connect to other web services from external to your web server? That would verify your routing is fine.

Here is the top of my config, hope it helps.
listen:
hostname: ‹ localhost ›
port: 8082

.# Correspond to your reverse proxy server_name/listen configuration (i.e., your public PeerTube instance URL)
webserver:
https: true
hostname: ‹ videos.mywebsite.com ›
port: 443

Hi Tyler_h,
Thanks for your attention. :wink: I’ve checked and altered my production.yaml and changed from 0.0.0.0 to and that works as well. Likely is a better setting, however i still have no luck with installing plugin or themes. Here is my setup there.

listen:
  hostname: <localhost>
  port: 9000

# Correspond to your reverse proxy server_name/listen configuration (i.e., your public PeerTube instance URL)
webserver:
  https: true
  hostname: 'modvid.com'
  port: 443

I’m not sure how to check other external services to the webserver aside from plugins and themes. Can you suggest a means to test that? I’ll keep grinding away at the issue. Pretty sure its not a permissions issue, have checked ownership carefully.

I’m configuring my server to handle a couple other virtual hosts and created a conflict last night while installing phpmyadmin. Apache2 got installed and/or a second instance of nginx in the process and wound up fighting over binding to the host ip on port 80 with a bad exit. Spent a couple hours fighting to restart nginx, Had to uninstall apache2 and reinstalling nginx, then recreate my peertube nginx conf, but finally got things working again. Was sweating for a bit there. :stuck_out_tongue:

If you can only browse the website from localhost, your next step is to get the site browsable from your LAN, once that is functional, get your websites browsable from WAN.

If the 502 bad gateway is the issue, make sure the peertube service is running with
sudo systemctl restart peertube && sudo journalctl -fu peertube

Try setting the trust_proxy configuration key to include your reverse proxy’s IP addresses. Also, ensure that the server user (not root) has the necessary permissions to install plugins.

The website is resolving normally since changing the hostname to 0.0.0.0 in production.yaml. Its reachable externally and not just on local server or lan. https://modvid.com . Only thing not working is the plugins/themes install atm as far as i can tell. it does seem like a reverse proxy issue i think?

The server user Peertube is the owner of /peertube/storage/plugins and for the entire host directory (drwxr-xr-x or 755). In debian 11 plasma kde the gui doesn’t show it as having execute in the display. (execute is missing from check box options oddly). I’ve been logged in as root user for the peertube website itself. It seems like if i can’t install plugins or themes, then i shouldn’t be able to upload/process videos (which i can). My production.yaml had this setting.

trust_proxy:
- 'loopback'

I attempted to switch that to my global fixed ip, also to the localhost ip. And restarted nginx each time. Neither settings seemed to make a difference I don’t know enough about how reverse proxy functions to understand how it should be set up with peertube yet. but i’m going to learn. thanks for help and suggestions.

Hi @shakane ,

Did you resolve your problem ?

This is not an answer to your question, this is a side note :

peertube in http on port 9000 should not be exposed on the web, only https port of nginx that does the redirect and normaly localhost is fine if both nginx and peertube are run from same host.

Port 9000 should anyway not be accessible from internet, this can be done by not activating port forwarding for 9000 or filter it though firewall. Only nginx need to forward to his port

What is your nginx configuration, did you copy and adapt this provided by peertube project itself ? This is PeerTube/support/nginx/peertube at develop · Chocobozzz/PeerTube · GitHub

proxy_pass http://backend;

where backend can be 127.0.0.1: 9000.

upstream backend {
server 127.0.0.1:9000;
}

If your problem is not resolved some context is needed since peertube can be installed in different ways :

How is peertube installed ? Is there any docker involved ? Under which user is it running ?
How is nginx installed ?
How internet is done ? Is there a internet box for selfhosting used or through a hosting service ?

What are logs of nginx ? According to mentioned configuration those are configured in /var/log/nginx/peertube.access.log and /var/log/nginx/peertube.error.log.

Kind Regards