[Résolu] Configuration trust_proxy static introuvable


#1

Bonjour,

J’ai mis en place une plateforme peertube avec un reverse proxy en utilisant l’option trust_proxy
Tout fonctionne bien sauf les /static/avatar et static/thumbnails

J’ai un not found et rien dans les logs

voici à quoi ressemble ma config nginx

server {
    if ($host = peetube.tld) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name peetube.tld;

    access_log /var/log/video.access.log;
    error_log /var/log/video.error.log;

    location /.well-known/acme-challenge/ {
      default_type "text/plain";
      root /var/www/certbot;
    }
    location / { return 301 https://$host$request_uri; }
}

server {
  server_name peetube.tld;

  listen 443 ssl http2; # managed by Certbot
  ssl_certificate /etc/letsencrypt/live/peetube.tld/fullchain.pem; # managed by Certbot
  ssl_certificate_key /etc/letsencrypt/live/peetube.tld/privkey.pem; # managed by Certbot
  include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

  # Configure with your resolvers
  # resolver $DNS-IP-1 $DNS-IP-2 valid=300s;
  # resolver_timeout 5s;

  # Enable compression for JS/CSS/HTML bundle, for improved client load times.
  # It might be nice to compress JSON, but leaving that out to protect against potential
  # compression+encryption information leak attacks like BREACH.
  gzip on;
  gzip_types text/css text/html application/javascript;
  gzip_vary on;

  # Enable HSTS
  # Tells browsers to stick with HTTPS and never visit the insecure HTTP
  # version. Once a browser sees this header, it will only visit the site over
  # HTTPS for the next 2 years: (read more on hstspreload.org)
  #add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";

  access_log /var/log/video.access.log;
  error_log /var/log/video.error.log;

  # Bypass PeerTube for performance reasons. Could be removed
  location ~ ^/static/(thumbnails|avatars)/ {
    if ($request_method = 'OPTIONS') {
      add_header 'Access-Control-Allow-Origin' '*';
      add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
      add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
      add_header 'Access-Control-Max-Age' 1728000;
      add_header 'Content-Type' 'text/plain charset=UTF-8';
      add_header 'Content-Length' 0;
      return 204;
    }

    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
    add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

    # Cache 2 hours
    add_header Cache-Control "public, max-age=7200";

    root /var/www/peertube/storage;

    rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break;

    proxy_pass http://192.168.1.1:9000;

    try_files $uri /;

  }

  # Bypass PeerTube for performance reasons. Could be removed
  location ~ ^/static/(webseed|redundancy)/ {
    # Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client
    limit_rate 800k;

    proxy_pass http://192.168.1.1:9000;

    if ($request_method = 'OPTIONS') {
      add_header 'Access-Control-Allow-Origin' '*';
      add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
      add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
      add_header 'Access-Control-Max-Age' 1728000;
      add_header 'Content-Type' 'text/plain charset=UTF-8';
      add_header 'Content-Length' 0;
      return 204;
    }

    if ($request_method = 'GET') {
      add_header 'Access-Control-Allow-Origin' '*';
      add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
      add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

      # Don't spam access log file with byte range requests
      access_log off;
    }

    root /var/www/peertube/storage;

    rewrite ^/static/webseed/(.*)$ /videos/$1 break;
    rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break;

    try_files $uri /;

  }

  # Websocket tracker
  location /tracker/socket {
    # Peers send a message to the tracker every 15 minutes
    # Don't close the websocket before this time
    proxy_read_timeout 1200s;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_pass http://192.168.1.1:9000;
  }
}

https://peertube.tld/static/thumbnails/dc3b74b6-9b97-4061-bb71-d32ad1549c50.jpg

me renvoi page introuvable

Merci de votre aide :slight_smile:


#2

Si l’instance PeerTube est sur une autre machine que le reverse proxy, il faut que tu supprimes les sections https://github.com/Chocobozzz/PeerTube/blob/develop/support/nginx/peertube#L117 et https://github.com/Chocobozzz/PeerTube/blob/develop/support/nginx/peertube#L68


#3

Merci c’est réglé :wink: