Advice? Docker, nginx & reverse proxies

Hi all,

I’m not very experienced, so would really appreciate your advice on my nginx setup. Is it safe, or do you think it will lead to performance issues/errors?

I tried to use the default nginx config included in the docker volume
(docker-compose.yaml version: 3.3). I think this didn’t work because:

  • I am running several applications and subdomains on the same VPS
  • Using a nginx reverse proxy config
  • The only way I could get SSL working is by putting the cert in the http block in nginx.conf, with server blocks inside it

I tried adding in what was in the default peertube nginx file line-by-line. But the below is the only thing that works for me:


server {
    listen              443 ssl;
    server_name         subdomain.example.org;
access_log /var/log/nginx/peertube.access.log; # reduce I/0 with buffer=10m flush=5m
error_log  /var/log/nginx/peertube.error.log;

      location / {
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-Host $host;
       proxy_set_header X-Forwarded-Server $host;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_set_header X-Real-IP $remote_addr;
	   proxy_set_header X-Forwarded-For
	   $proxy_add_x_forwarded_for;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection $connection_upgrade;
       proxy_pass http://127.0.0.1:9000;
      }

      client_max_body_size 2G;

}
# additional settings below this, in the http block:
    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    gzip on;
```

I’ve just been able to solve my problem and add the recommended peertube nginx server block to my nginx.conf

I ran:

docker inspect <peertube-container-ID>

to get the IP address of my peertube docker container.

Then, I added this IP adress into the upstream backend nginx block, like so:

upstream backend {

  server  <the-docker-container-IP-address>:9000;

}

Also, as others have said, I did comment out this bit:

#   location ~ ^/client/(.*\.(js|css|png|svg|woff2|otf|ttf|woff|eot))$ {
#     add_header Cache-Control "public, max-age=31536000, immutable"; # Cache 1 year

#     alias /var/www/peertube/peertube-latest/client/dist/$1;
#   }

Before doing this, I was getting a lot of nginx 502 errors. Hope this helps others having the same nginx config nightmare!