I'm trying to get Nginx working as a reverse proxy for the Transmission web client. Both are in separate Docker containers with Docker Compose.
Ive read previous similar questions, but these have not worked for me:
https://unix.stackexchange.com/questions/64812/get-transmission-web-interface-working-with-web-server
https://stackoverflow.com/questions/15391073/nginx-transmission-daemon-url-rewrite
Nginx gives me the error:
[error] 6#6: *3 "/etc/nginx/html/transmission/web/index.html" is not found (2: No such file or directory), client: 172.18.0.1, server: torrent.localhost, request: "GET /transmission/web/ HTTP/1.1", host: "torrent.localhost"
This makes me suspect that the proxy_pass is not working correctly as its still trying to grab the html file from the file system.
Any help would be very much appreciated!
- When I go to http://localhost i get
hello world!
- When I got to http://torrent.localhost I get a native prompt for username and password
- When I type in the username and password I get redirected to http://torrent.localhost/transmission/web/ with a
404: Not Found
- When I go to http://torrent.localhost:9091 I get the native prompt, however it logins in and continues to the Transmission web client successfully
docker-compose.yml:
version: "2"
services:
nginx:
image: nginx
container_name: nginx-proxy
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./www:/data/www
ports:
- "80:80"
- "443:443"
transmission:
image: linuxserver/transmission
container_name: transmission
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- USER=username
- PASS=password
volumes:
- ./transmission/config:/config
- ./transmission/downloads:/downloads
- ./transmission/watch:/watch
ports:
- "9091:9091"
- "51413:51413"
- "51413:51413/udp"
restart: unless-stopped
nginx.conf:
events {
}
http {
server {
listen 80;
server_name localhost 127.0.0.1;
root /data/www;
location = / {
index index.html;
}
}
server {
server_name torrent.localhost;
location = / {
proxy_read_timeout 300;
proxy_pass_header X-Transmission-Session-Id;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://transmission:9091;
}
}
}
index.html:
hello world!
Best Answer
Your problem lies in the equal sign after "location". The equal sign can be used if the location needs to match the EXACT request URI.
You might want to remove the equal sign ("=") like this: