Yooooomi / your_spotify

Self hosted Spotify tracking dashboard
GNU General Public License v3.0
2.77k stars 110 forks source link

Working with Cloudflare Tunnel #283

Closed hoiber closed 8 months ago

hoiber commented 11 months ago

Hey, has anyone had any success using a cloudflare tunnel? Cant seem to get it to work.

Have tried setting the API_ENDPOINT: http://serv-spotify.somedomain.xo as recommended in similar issues with reverse proxies (I know cloudflare is different but thought it was worth a go)

Main issue is the web reports it cant find the server.

This could be completely not doable but thought someone might have got it working.

Config Below:

version: "3"

services: server: image: yooooomi/your_spotify_server restart: always ports:

Cloudflare Settings

image
arriej commented 11 months ago

Hi,

Ive been looking at your config and trying to figure out whats wrong with it. So far everything looks like its supposed to work as intended. Looking at other cloud-flare issues and domain issues its often caused by cache. So maybe you can clear you cache or try a different browser.

In my compose config i did include CORS: all not sure if this is going to fix your issue though.

kacperpaluch commented 11 months ago

I have the same problem with Cloudflare.

hoiber commented 11 months ago

Hi,

Ive been looking at your config and trying to figure out whats wrong with it. So far everything looks like its supposed to work as intended. Looking at other cloud-flare issues and domain issues its often caused by cache. So maybe you can clear you cache or try a different browser.

In my compose config i did include CORS: all not sure if this is going to fix your issue though.

Thanks, it was indeed the stupid cache!

arriej commented 11 months ago

I have the same problem with Cloudflare.

Hi, just saying u got the same output, but post none of your configs or what U have tried to solve it isn't going to get you any further.

Show us your docker compose and cloud flare tunnels settings. Or try to clear your cache or try a different browser.

hkamran80 commented 11 months ago

I got Cloudflare Tunnels working with the following Compose file.

services:
  server:
    image: yooooomi/your_spotify_server
    depends_on:
      - mongo
    links:
      - mongo
    environment:
      API_ENDPOINT: [server URL]
      CLIENT_ENDPOINT: [client URL]
      SPOTIFY_PUBLIC: [redacted]
      SPOTIFY_SECRET: [redacted]
    restart: always

  mongo:
    image: mongo:6 
    volumes:
      - ./db:/data/db

  web-client:
    image: yooooomi/your_spotify_client
    depends_on:
      - server
    environment:
      API_ENDPOINT: [client URL]
    restart: always

  server-tunnel:
    image: cloudflare/cloudflared:latest
    depends_on:
      - server
    environment:
      TZ: [timezone]
    restart: unless-stopped
    command: tunnel --no-autoupdate run --token [server token]

  web-tunnel:
    image: cloudflare/cloudflared:latest
    depends_on:
      - web-client
    environment:
      TZ: [timezone]
    restart: unless-stopped
    command: tunnel --no-autoupdate run --token [client token]
Yooooomi commented 10 months ago

Any update on this?

pentafive commented 8 months ago

Any update on this?

I found that the above docker-compose worked well for me. The only thing I'd add is that you need to define the two tunnels in the zero trust dashboard. Here's how:

  1. Open the Cloudflare Zero Trust dashboard, then select Access, then Tunnels.
  2. Create a new tunnel for the web-client. Come up with a hostname.domain for the [client URL] and point it to http://web-client:3000. Take the tunnel token and put in the [client token] in the docker-compose. Update [client URL] in the docker-compose with the public hostname used in the tunnel config.
  3. Then make a 2nd tunnel for the server. Put a hostname.domain for the [server URL] and point it to http://server:8080. Take the tunnel token and put in the [servertoken] in the docker-compose. Update [server URL] in the docker-compose with the public hostname used in the tunnel config.

Hope that helps!

-JD