airsonic / airsonic-docs

Documentation for the Airsonic project
GNU General Public License v3.0
14 stars 48 forks source link

Caddy Reverse Proxy not working #79

Open samcro1967 opened 5 years ago

samcro1967 commented 5 years ago

I am running airsonic in a Docker container with URL base set as airsonic.

CADDYFILE

https://mydomain.net/ http://localhost/ {
    proxy / 192.168.1.103:4040/airsonic {          # https://github.com/airsonic/airsonic
    transparent
    without /airsonic
  }
}

https://mydomain.net gets redirected to http//mydomain.net after I provide valid user name and password. Seems like Airsoni is redirecting HTTPS traffic to HTTP which is not configured in Caddy or allwed through the firewall.

Hoping I am missing something simple.

Airsonic log file airsonic.log

jooola commented 5 years ago

You might want to try with some forward headers :

Here is what I found, not sure how cddy works, but you could try it (you need to replace host with something, not sure if you can get the host dynamically).

header_upstream X-Forwarded-Proto https
header_upstream X-Forwarded-Host <host>

Would you mind sharing your configuration once you have a working setup ? Even bettre would be to open a PR on the airsonic-docs repo with your configuration !

samcro1967 commented 5 years ago

The transparent command for Caddy does all of that already if I am understanding the documentation correctly:

transparent - Passes thru host information from the original request as most backend apps would expect. Shorthand for:

header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-For {remote}
header_upstream X-Forwarded-Port {server_port}
header_upstream X-Forwarded-Proto {scheme}
samcro1967 commented 5 years ago

Found some documentation I missed in the inital setup. This solved the issue.

You will also need to make sure Tomcat uses the correct headers for redirects. Stop your Airsonic server or docker image and:

nano /path/to/airsonic/config/airsonic.properties Add the following line to the bottom of the file:

server.use-forward-headers=true

https://airsonic.github.io/docs/proxy/caddy/

hayalci commented 3 years ago

Looks like this issue was accidentally reopened.