Page 1 of 1

Problems to login after setting a nginx proxy for Subsonic

PostPosted: Wed Dec 11, 2013 1:25 am
by piterdias
I started using nginx as a front-end in order to standardize my services access via sub-domains. It works well for pydio and webmail (RainLoop, very good), but Subsonic doesn’t log in.
There is no error message, it just returns to log in page instead of showing my music library.
See attached that even the colours and format of the front page is different (right version) compared to direct access (left version).
What am I doing wrong? I browse the forum and people with more complex setup (SSL, for example) where able to put nginx proxy for Subsonic up and running.

My setup is:
- Subsonic server
- HP microserver at home
- Ubuntu 13.10 x64
- Subsonic 4.9.beta2 (build 3634)
- Apache Tomcat/6.0.37, java 1.7.0_25
- Nginx server
- Digital Ocean cheap server (512MB, 20GB SSD)
- Ubuntu 13.10 x64
- nginx version: nginx/1.4.1 (Ubuntu)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --with-pcre-jit --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.4.1/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.4.1/debian/modules/nginx-dav-ext-module --add-module=/build/buildd/nginx-1.4.1/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.4.1/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.4.1/debian/modules/ngx_http_substitutions_filter_module
server {
listen 80;
server_name pydio.mydomain.com;
location / {
proxy_pass http://aaa.bbb.ccc.ddd:9090/pydio/;
}
}

server {
listen 80;
server_name subsonic.mydomain.com;
location / {
proxy_pass http://aaa.bbb.ccc.ddd:8070/subsonic/;
}
}

server {
listen 80;
server_name webmail.mydomain.com;
location / {
proxy_pass http://aaa.bbb.ccc.ddd:9090/webmail/;
}
}

Re: Problems to login after setting a nginx proxy for Subson

PostPosted: Wed Dec 11, 2013 2:09 am
by daneren2005
If I remember correctly you need to specify a context path in the /etc/default/subsonic config. Ex, mine with https instead of http:

HOST=127.0.0.1
PORT=0
HTTPS_PORT=4040
CONTEXT_PATH=/subsonic

SUBSONIC_ARGS="--max-memory=500 --context-path=${CONTEXT_PATH} --port=${PORT} --https-port=${HTTPS_PORT}"

Re: Problems to login after setting a nginx proxy for Subson

PostPosted: Thu Dec 12, 2013 12:27 am
by piterdias
Those variables are used in the standalone version so it doesn't seem to apply for an installation under Tomcat.
I will dig a little further because it must be something related to nginx, once the Apache, in other server I have, proxy works.

Thanks for replying.,

Re: Problems to login after setting a nginx proxy for Subson

PostPosted: Thu Dec 12, 2013 1:36 am
by piterdias
Nginx is appending the ";jsessionid=" piece to every single address and that seems to be hurting Subsonic behavior.
Could someone using Nginx as a proxy give some tip? It works fine under Apache but I am trying to keep a very small footprint in this proxy server.

Re: Problems to login after setting a nginx proxy for Subson

PostPosted: Fri Jan 31, 2014 8:36 pm
by Eluminare
Hello together,

I'm experiencing a similiar error.

I'm running an tomcat 7 web server with subsonic behind an apache reverse proxy which is using the ajp connector (port 8009).
Now I've tried to change from apache reverse proxy to nginx, because there is a better performance and it's easier to configure multiple domains...
But if I try to login, I get no notice and I can't see the "jsessionid....." in the address bar.

Does anybody have a solution for this?

Greetings from Germany

Eluminare

Re: Problems to login after setting a nginx proxy for Subson

PostPosted: Fri Jan 31, 2014 9:02 pm
by daneren2005
Well I got the same error before I added a context path to the jetty configuration. I have no idea what the Tomcat equivalent is since I don't use it, but I imagine that would fix it.

Re: Problems to login after setting a nginx proxy for Subson

PostPosted: Sat Feb 01, 2014 2:07 pm
by Eluminare
After searching in over 100 forums, I got a solution for my problem.
That is my sites-enabled/ config for the domain in nginx:

server {
server_name DOMAIN;
location ^~/madsonic/ {
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_max_temp_file_size 1M;
proxy_pass http://backendserver:PORT/madsonic/;
}
}

If have tried this with subsonic and madsonic. Madsonic is running in a standalone version, Subsonic is running as a war file. The trick is to add a ^~ after location...

Please let me know, if this is helpful for you. :!: