supysonic icon indicating copy to clipboard operation
supysonic copied to clipboard

Be nice with reverse proxies

Open shammash opened this issue 10 years ago • 4 comments

Please consider adding a middleware like http://flask.pocoo.org/snippets/35/ so supysonic can run below some path other than / .

Thank you.

shammash avatar Apr 27 '14 19:04 shammash

Is this solved by running supysonic as WSGI app?

The application path is defined by the WSGIScriptAlias ... ... line, see the "As an Apache WSGI application" in the README.md for example config.

knealmarc avatar Jan 13 '16 09:01 knealmarc

It works for me as a wsgi app behind a reverse proxy.

Here's the log from my main server:

==> /var/log/apache2/example.com.access.log <==
2001:470:8:ec:: - - [27/Mar/2017:15:56:37 -0400] "GET /supysonic/rest/stream.view?u=bjmgeek&p=enc:XXXXXXXX&f=jsonp&v=1.8.0&c=Jamstash&id=XXXXXX&salt=5454 HTTP/1.1" 206 3789114 "http://www.jamstash.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"

Here's the log from the reverse proxy:

==> /var/log/apache2/music.example.com.access.log <== 
50.164.119.132 - - [27/Mar/2017:15:56:37 -0400] "GET /rest/stream.view?u=bjmgeek&p=enc:XXXXXXXX&f=jsonp&v=1.8.0&c=Jamstash&id=XXXXXXXX&salt=5454 HTTP/1.1" 206 3789122 "http://www.jamstash.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"

apache config for the reverse proxy:

<VirtualHost *:80>
        ServerName music.example.com
        CustomLog /var/log/apache2/music.example.com.access.log combined

        ProxyPass / http://example.com/supysonic/
        ProxyPassReverse / http://example.com/supysonic/
</VirtualHost>

apache config for main site /supysonic:

WSGIScriptAlias /supysonic /home/bjmgeek/public_html/programs/supysonic/cgi-bin/supysonic.wsgi 
<Directory /home/bjmgeek/public_html/programs/supysonic/cgi-bin> 
    WSGIApplicationGroup %{GLOBAL} 
    WSGIPassAuthorization On 
    Order deny,allow 
    Allow from all 
</Directory>

It's not perfect, http://music.example.com redirects to http://music.example.com// but it works fine with API calls.

bjmgeek avatar Mar 27 '17 20:03 bjmgeek

update: when I logged out, this broke, because I got an endlessly growing redirect loop. The culprit seems to be "GET /supysonic/supysonic/user/login?returnUrl=%2Fsupysonic%2Fsupysonic%2Fuser%2Flogin%3FreturnUrl%3D%252Fsupysonic%252Fsupysonic%252Fuser%252Flogin%253FreturnUrl%253D%25252Fsupysonic%25252Fsupysonic%25252Fuser%25252Flogin%25253FreturnUrl ad infinitum.

bjmgeek avatar Mar 27 '17 20:03 bjmgeek

I'm not 100% sure this is what OP was looking for, but I believe that @knealmarc was right about being able to configure this using wsgi settings. I'm running uwsgi behind Caddy with supysonic mounted at /music, and I've yet to experience any problems, (including problems logging out). I'm running uwsgi with the options:

--mount="/music=/path/to/server.py" --manage-script-name --module main --callable app --http :5000

and the relevant block of my caddyfile is

proxy /music localhost:5000 {
     transparent
}

I can connect to https://myserver.com/music to get to the supysonic main page, and everything works fine from there.

Alch-Emi avatar Oct 14 '18 19:10 Alch-Emi