Page 1 of 1

Subsonic server outbound proxy

PostPosted: Wed Apr 19, 2017 4:51 pm
by cromnet
I am looking for a way to set proxy server settings for the subsonic server service. To be clear this is regarding forward proxy to the internet such as Squid, this post is not about reverse proxy like Apache. My subsonic server is behind a firewall and is only able to access the internet through a proxy server.

I have been using a transparent proxy for any outbound HTTP connections. This however does not work for HTTPS connections, the application needs to be aware of the proxy server so it can use the CONNECT tunnel to establish an encrypted HTTPS connection through the firewall. I recently tried to add some album art through the subsonic web interface and encountered the error below.

My question is if there is a way to set the subsonic to use a proxy server through java opts or other method?

Subsonic Version: 6.0 (build a7857c) – April 30, 2016
Server Version: jetty-6.1.x, java 1.7.0_121, Linux
Hardware Platform: Debian Jessie

Error:
Failed to download image.
org.apache.http.conn.ConnectTimeoutException: Connect to lastfm-img2.akamaized.net:443 timed out

Log:
WARN CoverArtService - Failed to save cover art for album 16962
org.apache.http.conn.ConnectTimeoutException: Connect to lastfm-img2.akamaized.net:443 timed out
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:416)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:644)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at net.sourceforge.subsonic.ajax.CoverArtService.saveCoverArt(CoverArtService.java:95)
at net.sourceforge.subsonic.ajax.CoverArtService.setCoverArtImage(CoverArtService.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.directwebremoting.impl.CreatorModule$1.doFilter(CreatorModule.java:172)
at org.directwebremoting.impl.CreatorModule.executeMethod(CreatorModule.java:184)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:353)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:306)
at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:110)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:211)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:185)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:144)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:166)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) [9/6358]
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:173)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at net.sourceforge.subsonic.filter.RequestEncodingFilter.doFilter(RequestEncodingFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at net.sourceforge.subsonic.filter.ParameterDecodingFilter.doFilter(ParameterDecodingFilter.java:54)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at net.sourceforge.subsonic.filter.BootstrapVerificationFilter.doFilter(BootstrapVerificationFilter.java:59)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:313)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:227)
at org.mortbay.jetty.security.SslSocketConnector$SslConnection.run(SslSocketConnector.java:626)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

Re: Subsonic server outbound proxy

PostPosted: Thu Apr 27, 2017 6:33 pm
by sindre_mehus
I suggest you try to set the Java system property "-Dhttp.proxyHost=xxxx"

https://docs.oracle.com/javase/8/docs/t ... oxies.html

Re: Subsonic server outbound proxy

PostPosted: Mon May 01, 2017 6:42 pm
by cromnet
thanks for the suggestion

I tried this using both -Dhttp.proxyHost/Dhttp.proxyPort only, and also with http and Dhttps.proxyHost/Dhttps.proxyPort. From netstat I can see the HTTP connections going through the proxy now, however the HTTPS connections are still not using the proxy and are still failing

let me know if there is anything else that can be done

thanks again
Ryan

Re: Subsonic server outbound proxy

PostPosted: Wed Nov 29, 2017 10:18 pm
by cromnet
I did eventually get this working with -DsocksProxyHost. for whatever reason the settings from Dhttps.proxyHost/Dhttps.proxyPort are not used. When DsocksProxyHost and Dhttp.proxyHost/Dhttp.proxyPort are both specified, the HTTPS connections go through the SOCKS proxy as well as certain HTTP connections. Again i'm not sure of why but I still need to specify Dhttp.proxyHost/Dhttp.proxyPort because certain http connection use that proxy while others use the SOCKS proxy.