Do note that this seems to still throw a single 409 on the first RPC call, but this is just in the logs and otherwise seems to work just fine
To get around the /transmission not working directly and need to go to /transmission/web, I've added the rewrite rule. The remaining parts were already provided by @replay.
I have an SSL redirect and a few other services running on this nginx so can't just proxy pass everything through /
Assumption - all non '/' terminated paths are redirected to /, e.g. mydomain.com/transmission will be redirected to mydomain.com/transmission/
# Redirect /transmission to /transmission/web/ to get around the CSRF token issues
location = /transmission/ {
return 301 /transmission/web/;
}
# Actually proxy with the session id header
# We need a separate proxy for /transmission, which is the webpage and assets and a separate for the rpc calls which go to the server root
location ^~ /transmission {
include proxy.conf;
proxy_pass http://127.0.0.1:9091/transmission;
proxy_pass_header X-Transmission-Session-Id;
}
location ^~ /transmission/rpc {
include proxy.conf;
proxy_pass http://127.0.0.1:9091;
}
I believe the proxy conf details are just defaults
# Version 2023/02/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/proxy.conf.sample
# Timeout if the real server is dead
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
# Proxy Connection Settings
proxy_buffers 32 4k;
proxy_connect_timeout 240;
proxy_headers_hash_bucket_size 128;
proxy_headers_hash_max_size 1024;
proxy_http_version 1.1;
proxy_read_timeout 240;
proxy_redirect http:// $scheme://;
proxy_send_timeout 240;
# Proxy Cache and Cookie Settings
proxy_cache_bypass $cookie_session;
#proxy_cookie_path / "/; Secure"; # enable at your own risk, may break certain apps
proxy_no_cache $cookie_session;
# Proxy Header Settings
#proxy_set_header Connection $connection_upgrade;
proxy_set_header Early-Data $ssl_early_data;
proxy_set_header Host $host;
proxy_set_header Proxy "";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Method $request_method;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-Uri $request_uri;
proxy_set_header X-Original-Method $request_method;
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header X-Real-IP $remote_addr;