Setup Nginx Reverse Proxy (IP-Based Setup)¶
In this step, we configure Nginx to:
- Reverse proxy requests to TG-FileStream
- Handle HTTP traffic
- Properly stream large files
⚠ At this stage, we are NOT using a domain. We will configure Nginx using the server IP address.
1. Install Nginx¶
Enable and start Nginx:
2. Ensure TGFS Service Is Running¶
Make sure the main service is active:
The application should be running on:
<Bind Address>:<PORT>
3. Create Nginx Configuration¶
Create a new site configuration:
Paste:
upstream aiohttp_backend {
least_conn;
keepalive 32;
server <Bind Address>:<PORT> max_fails=3 fail_timeout=30s;
}
server {
listen 80;
server_name _;
location / {
proxy_pass http://aiohttp_backend;
proxy_http_version 1.1;
proxy_buffering off;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Adjust:
- Replace
<Bind Address>with theHOSTvalue from your.env. - Replace
<PORT>with thePORTvalue from your.env.
Example
upstream aiohttp_backend {
least_conn;
keepalive 32;
server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
server_name _;
location / {
proxy_pass http://aiohttp_backend;
proxy_http_version 1.1;
proxy_buffering off;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
4. Enable Site¶
Remove the default site (recommended):
5. Test Configuration¶
If successful:
Reload Nginx:
6. Test Using Server IP¶
Get your server IP:
Open in browser:
Or test using curl:
If configured correctly, requests should be forwarded to TGFS.
Troubleshooting¶
502 Bad Gateway¶
Check TGFS status:
Check logs: