Last active
January 30, 2024 09:26
-
-
Save bathizte/80f40f27f02452f98fd6 to your computer and use it in GitHub Desktop.
Lighttpd CORS reverse proxy for transmission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lighttpd as a CORS reverse proxy to Transmission XML-RPC API | |
server.modules = ( | |
"mod_rewrite", | |
"mod_setenv", | |
"mod_proxy" | |
) | |
server.document-root = "/var/www" | |
# CORS preflighted request (HTTP OPTIONS) not handled yet by Transmission : Emulate a 200 OK | |
$HTTP["request-method"] =~ "^OPTIONS$" { | |
url.rewrite = ( "^.*$" => "/index.html") | |
} | |
# Proxy other requests to Transmission (YMMV) | |
$HTTP["request-method"] =~ "^(GET|POST)$" { | |
proxy.server = ( | |
"/bt/rpc" => ( | |
"transmission-rpc" => ( | |
"host" => "127.0.0.1", | |
"port" => 9091 | |
) | |
) | |
) | |
} | |
# CORS Headers | |
setenv.add-response-header = ( | |
"Access-Control-Allow-Origin" => "*", | |
"Access-Control-Allow-Headers" => "accept, origin, x-requested-with, content-type, x-transmission-session-id", | |
"Access-Control-Expose-Headers" => "X-Transmission-Session-Id", | |
"Access-Control-Allow-Methods" => "GET, POST, OPTIONS" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The cors headers are needed only if the method is OPTIONS so you can try: