Using NGINX as Reverse Proxy
Info
If you are experiencing problems with NGINX, such as failed uploads, connection errors, broken thumbnails, and video playback problems, please consider asking the NGINX community for advice, as we do not specialize in supporting their product, which is notoriously difficult to configure.
This tutorial explains, how to configure NGINX WebSocket connections between your client and backend services.
http {
server {
listen 80 ssl;
listen [::]:80 ssl;
server_name example.com;
client_max_body_size 500M;
# With SSL via Let's Encrypt
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/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
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://localhost:2342;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 500M;
}
}
}
At the very least you will need to adapt server_name and the ssl_certificate/ssl_certificate_key paths to match your setup. Please refer to their official documentation for further details.
View "Pitfalls and Common Mistakes" ›
Running the proxy in a different container or host
Starsky only trusts the X-Forwarded-For/X-Forwarded-Proto headers when they come directly
from 127.0.0.1/::1. That's enough when NgInx runs on the same host as Starsky (as in the
example above, where proxy_pass points at localhost). If your reverse proxy instead runs in a
different Docker container or on a different host, tell Starsky to trust it explicitly:
app__TrustedProxies__0=172.17.0.1
(use the proxy's own address, or a CIDR range such as 10.0.0.0/8). Once any entry is set, only
the listed addresses are trusted and the default loopback trust is dropped, so also add
127.0.0.1 and ::1 if a proxy on the same host should keep working. Hostnames are not
supported, and invalid entries are skipped (a message is written to the console). Do not try to make
Starsky trust every client — that would let any visitor spoof their IP address in
X-Forwarded-For, bypassing the login/register rate limiting and, if NoAccountLocalhost is
enabled, the localhost auto-login check.
Why Use a Proxy?
If you install Starsky on a public server outside your home network, always run it behind a secure HTTPS reverse proxy. Your files and passwords will otherwise be transmitted in clear text and can be intercepted by anyone, including your provider, hackers, and governments. Backup tools and file sync apps may refuse to connect as well.