Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with reverse proxy #31

Open
wallace11 opened this issue Aug 7, 2021 · 22 comments
Open

Doesn't work with reverse proxy #31

wallace11 opened this issue Aug 7, 2021 · 22 comments

Comments

@wallace11
Copy link

I'm using SWAG with https://github.com/linuxserver/docker-mods/tree/swag-auto-proxy.
Literally every service that I throw at it works except for plugsy.
I'm getting a "500 Internal Server Error.".

Here's the relevant parts from my docker-compose for trying to replicate this:

version: '3.8'
services:

  swag:
    image: ghcr.io/linuxserver/swag
    container_name: swag
    environment:
      - DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:swag-auto-proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 443:443
      - 80:80
    cap_add:
      - NET_ADMIN
    restart: unless-stopped

  plugsy:
    image: plugsy/core
    container_name: plugsy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 3000:3000
    labels:
      - swag=enable
      - swag_port=3000
    restart: unless-stopped
@Inlustra
Copy link
Collaborator

Inlustra commented Aug 7, 2021

Can you post the logs from the container?
I don't the the reverse-proxy side of this should affect anything!

@wallace11
Copy link
Author

There you go


 ApolloError: Unexpected token G in JSON at position 0
     at new ApolloError (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/errors/errors.cjs.js:31:28)
     at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/core/core.cjs.js:1493:19
     at both (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:963:53)
     at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:72
     at new Promise (<anonymous>)
     at Object.then (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:24)
     at Object.error (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:964:49)
     at notifySubscription (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:140:18)
     at onNotify (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:179:3)
     at SubscriptionObserver.error (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:240:7) {
   graphQLErrors: [],
   networkError: SyntaxError [ServerParseError]: Unexpected token G in JSON at position 0
       at JSON.parse (<anonymous>)
       at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/link/http/http.cjs.js:18:25
       at runMicrotasks (<anonymous>)
       at processTicksAndRejections (internal/process/task_queues.js:95:5) {
     response: Response {
       size: 0,
       timeout: 0,
       [Symbol(Body internals)]: [Object],
       [Symbol(Response internals)]: [Object]
     },
     statusCode: 400,
     bodyText: 'GET query missing.'
   },
   extraInfo: undefined
 }

@Inlustra
Copy link
Collaborator

Inlustra commented Aug 9, 2021

Apologies for the late reply, this has definitely not dropped off of my radar, unfortunately I'm without internet so it's proving slow for me to test this.

Off the top of my head, perhaps this is something to do with the websocket side of the swag reverse proxy?
I don't know how that reverse proxy works unfortunately, have you tried accessing it without using the proxy?

@wallace11
Copy link
Author

Hi,
Yes, in my example I left the 3000 port exposed exactly for doing that comparison.
Accessing via mydomain.com:3000 works as opposed to plugsy.mydomain.com which doesn't.

I use more than a dozen of services, some are using websocket, doing the exact same thing, and only plugsy is behaving.

Maybe I'll take a look at the source code to see if you've got hard-coded urls, etc...

@Inlustra
Copy link
Collaborator

I host mine through a caddy proxy, so I'm sure it's something in Swag! As I say, if I have some more time, I'll deffo give this a go

@wallace11
Copy link
Author

I'll try to ask on the SWAG channel as well - will keep you posted.

@petersem
Copy link

petersem commented Aug 20, 2021

Failing with nginx proxy manager (500 error) with, or without, web socket support. I am also using self-signed certs from lets encrypt, so traffic comes in on https and then redirects to http.

error:   ┏ fail +256ms
error:   ┃ [1] Error: Request failed with status code 502
error:   ┃ [2]     at createError (/opt/prod/.yarn/cache/axios-npm-0.21.1-d192f6b3b3-864fb7b5d0.zip/node_modules/axios/lib/core/createError.js:16:15)
error:   ┃ [3]     at settle (/opt/prod/.yarn/cache/axios-npm-0.21.1-d192f6b3b3-864fb7b5d0.zip/node_modules/axios/lib/core/settle.js:17:12)
error:   ┃ [4]     at IncomingMessage.handleStreamEnd (/opt/prod/.yarn/cache/axios-npm-0.21.1-d192f6b3b3-864fb7b5d0.zip/node_modules/axios/lib/adapters/http.js:260:11)
error:   ┃ [5]     at IncomingMessage.emit (events.js:412:35)
error:   ┃ [6]     at endReadableNT (internal/streams/readable.js:1317:12)
error:   ┃ [7]     at processTicksAndRejections (internal/process/task_queues.js:82:21)
error:   ┗ [8] { component: 'websiteConnection', id: 'WEBSITE', error: 'Request failed with status code 502' }

@zilexa
Copy link

zilexa commented May 2, 2022

@Inlustra I have the exact same issue with Caddy, note I use Caddy-Docker-Proxy https://github.com/lucaslorentz/caddy-docker-proxy which is the same as Caddy but uses Labels (like Plugsy) to built a caddyfile dynamically.

All my other services that I proxy locally (not exposed through a webdomain) work fine, Plugsy is the only one giving me internal server error 500.

##_____________________ Caddy [SYSTEM/web-proxy]
  caddy:
    container_name: web-proxy
    image: lucaslorentz/caddy-docker-proxy:ci-alpine
    restart: always
    networks: 
      - web-proxy
    environment:
      - CADDY_INGRESS_NETWORKS=web-proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - $DOCKERDIR/caddy/caddy_data:/data
      - $DOCKERDIR/caddy/config:/config
    labels:
      caddy.email: $EMAIL
      #caddy.log.output: file /data/access.log
      plugsy.name: Caddy web proxy
      plugsy.category: System
    ports:
      - 443:443
      - 80:80
 plugsy:
    container_name: dashboard
    image: plugsy/core
    restart: always
    networks: 
      - web-proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 8888:3000
    labels:
      caddy: http://myhom.e
      caddy.reverse_proxy: "{{upstreams 3000}}"

There is definitely something funky with Plugsy here, I can access it via the port number 8888 in my case, (bypassing Caddy) but not via http://myhom.e/
If I switch to other dashboards like Flame it works fine.

Log:

info:    ┏ loadConnectors +0ms
info:    ┗ [1] { component: 'watchConfig', count: 1 }
info:    ┏ setInternalConnections +4ms
info:    ┗ [1] { component: 'connectionPool', count: 1 }
info:    ┏ No agent configured, will not publish connection results +1ms
info:    ┗ [1] { component: 'agent' }
info:    ▪ > Server listening at http://localhost:3000 as production +1ms
[ 'feather', 'ExternalLink' ] 2
ApolloError: request to http://home.e/graphql failed, reason: getaddrinfo ENOTFOUND g.o
    at new ApolloError (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/errors/errors.cjs.js:31:28)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/core/core.cjs.js:1493:19
    at both (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:963:53)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:72
    at new Promise (<anonymous>)
    at Object.then (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:24)
    at Object.error (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:964:49)
    at notifySubscription (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:140:18)
    at onNotify (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:179:3)
    at SubscriptionObserver.error (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:240:7) {
  graphQLErrors: [],
  networkError: FetchError: request to http://home.e/graphql failed, reason: getaddrinfo ENOTFOUND g.o
      at ClientRequest.<anonymous> (/opt/prod/.yarn/cache/node-fetch-npm-2.6.1-46c670dbc1-cbb171635e.zip/node_modules/node-fetch/lib/index.js:1461:11)
      at ClientRequest.emit (events.js:400:28)
      at Socket.socketErrorListener (_http_client.js:475:9)
      at Socket.emit (events.js:400:28)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    type: 'system',
    errno: 'ENOTFOUND',
    code: 'ENOTFOUND'
  },
  extraInfo: undefined
}

@zilexa
Copy link

zilexa commented May 11, 2022

@Inlustra I understand you have no time for this project anymore, but can you please confirm this bug? Otherwise we are wasting time trying to solve it via Caddy (v2.4 or newer) or NGinx.

You said you use Caddy, can you please confirm which version and/or share your caddyfile? As the above error happens with v2.4 and 2.5.1 was just released.

@Inlustra
Copy link
Collaborator

Inlustra commented May 11, 2022

I do intend to get back to the project but I've had a lot on recently. The caddyfile I use is super simple, there's really nothing to it:

dashboard.myproject.com {
        reverse_proxy plugsy:3000
}

As I say this may very well be an issue in Plugsy but it's not super clear as to why on a quick glance.

I'm also not sure how you want me to confirm that this bug exists without digging into caddy-docker-proxy which I don't have time for right now.

I wonder if it's something to do with the address being bound?

@zilexa
Copy link

zilexa commented May 12, 2022

Thanks so much! Just by confirming Caddy does work for you, it means I should be able to get it working as well with Caddy :)

@zilexa
Copy link

zilexa commented May 16, 2022

@Inlustra I can confirm the " 500 | internal server error" also happens with the regular caddy image (latest, which should be version 2.5.1). I also tested with caddy:2.2.1, same error. Not sure how you got it working, but it should be easy to reproduce when you have time.

  caddy:
    image: caddy:2.2.1
    restart: unless-stopped
    networks: 
     - caddy2
    ports:
      - 80:80
      - 443:443
    volumes:
      - $DOCKERDIR/caddy2/Caddyfile:/etc/caddy/Caddyfile
      - $DOCKERDIR/caddy2/caddy_data:/data
      - $DOCKERDIR/caddy2/caddy_config:/config

networks:
  caddy2:
    driver: bridge

$DOCKERDIR/caddy2/Caddyfile:

http://dashboard.myhome {
        reverse_proxy plugsy:3000
}

Full log:

info:    ┏ loadConnectors +0ms
info:    ┗ [1] { component: 'watchConfig', count: 1 }
info:    ┏ setInternalConnections +4ms
info:    ┗ [1] { component: 'connectionPool', count: 1 }
info:    ┏ No agent configured, will not publish connection results +1ms
info:    ┗ [1] { component: 'agent' }
info:    ▪ > Server listening at http://localhost:3000 as production +2ms
ApolloError: request to http://dashboard.myhome/graphql failed, reason: getaddrinfo ENOTFOUND dashboard.myhome
    at new ApolloError (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/errors/errors.cjs.js:31:28)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/core/core.cjs.js:1493:19
    at both (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:963:53)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:72
    at new Promise (<anonymous>)
    at Object.then (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:24)
    at Object.error (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:964:49)
    at notifySubscription (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:140:18)
    at onNotify (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:179:3)
    at SubscriptionObserver.error (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:240:7) {
  graphQLErrors: [],
  networkError: FetchError: request to http://dashboard.myhome/graphql failed, reason: getaddrinfo ENOTFOUND dashboard.myhome
      at ClientRequest.<anonymous> (/opt/prod/.yarn/cache/node-fetch-npm-2.6.1-46c670dbc1-cbb171635e.zip/node_modules/node-fetch/lib/index.js:1461:11)
      at ClientRequest.emit (events.js:400:28)
      at Socket.socketErrorListener (_http_client.js:475:9)
      at Socket.emit (events.js:400:28)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    type: 'system',
    errno: 'ENOTFOUND',
    code: 'ENOTFOUND'
  },
  extraInfo: undefined
}
ApolloError: request to http://dashboard.myhome/graphql failed, reason: getaddrinfo ENOTFOUND dashboard.myhome
    at new ApolloError (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/errors/errors.cjs.js:31:28)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/core/core.cjs.js:1493:19
    at both (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:963:53)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:72
    at new Promise (<anonymous>)
    at Object.then (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:24)
    at Object.error (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:964:49)
    at notifySubscription (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:140:18)
    at onNotify (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:179:3)
    at SubscriptionObserver.error (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:240:7) {
  graphQLErrors: [],
  networkError: FetchError: request to http://dashboard.myhome/graphql failed, reason: getaddrinfo ENOTFOUND dashboard.myhome
      at ClientRequest.<anonymous> (/opt/prod/.yarn/cache/node-fetch-npm-2.6.1-46c670dbc1-cbb171635e.zip/node_modules/node-fetch/lib/index.js:1461:11)
      at ClientRequest.emit (events.js:400:28)
      at Socket.socketErrorListener (_http_client.js:475:9)
      at Socket.emit (events.js:400:28)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    type: 'system',
    errno: 'ENOTFOUND',
    code: 'ENOTFOUND'
  },
  extraInfo: undefined
}
ApolloError: request to http://dashboard.myhome/graphql failed, reason: getaddrinfo ENOTFOUND dashboard.myhome
    at new ApolloError (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/errors/errors.cjs.js:31:28)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/core/core.cjs.js:1493:19
    at both (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:963:53)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:72
    at new Promise (<anonymous>)
    at Object.then (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:24)
    at Object.error (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:964:49)
    at notifySubscription (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:140:18)
    at onNotify (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:179:3)
    at SubscriptionObserver.error (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:240:7) {
  graphQLErrors: [],
  networkError: FetchError: request to http://dashboard.myhome/graphql failed, reason: getaddrinfo ENOTFOUND dashboard.myhome
      at ClientRequest.<anonymous> (/opt/prod/.yarn/cache/node-fetch-npm-2.6.1-46c670dbc1-cbb171635e.zip/node_modules/node-fetch/lib/index.js:1461:11)
      at ClientRequest.emit (events.js:400:28)
      at Socket.socketErrorListener (_http_client.js:475:9)
      at Socket.emit (events.js:400:28)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    type: 'system',
    errno: 'ENOTFOUND',
    code: 'ENOTFOUND'
  },
  extraInfo: undefined
}
ApolloError: request to http://dashboard.myhome/graphql failed, reason: getaddrinfo ENOTFOUND dashboard.myhome
    at new ApolloError (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/errors/errors.cjs.js:31:28)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/core/core.cjs.js:1493:19
    at both (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:963:53)
    at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:72
    at new Promise (<anonymous>)
    at Object.then (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:24)
    at Object.error (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:964:49)
    at notifySubscription (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:140:18)
    at onNotify (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:179:3)
    at SubscriptionObserver.error (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:240:7) {
  graphQLErrors: [],
  networkError: FetchError: request to http://dashboard.myhome/graphql failed, reason: getaddrinfo ENOTFOUND dashboard.myhome
      at ClientRequest.<anonymous> (/opt/prod/.yarn/cache/node-fetch-npm-2.6.1-46c670dbc1-cbb171635e.zip/node_modules/node-fetch/lib/index.js:1461:11)
      at ClientRequest.emit (events.js:400:28)
      at Socket.socketErrorListener (_http_client.js:475:9)
      at Socket.emit (events.js:400:28)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    type: 'system',
    errno: 'ENOTFOUND',
    code: 'ENOTFOUND'
  },
  extraInfo: undefined
}

I really hope you find time to have a look, probably it is an easy fix because log shows Apollo is trying to find http://dashboard.myhome/graphql, I suppose that is wrong, as the domain is not proxied inside the container itself of course.

@airtonix
Copy link

airtonix commented Jul 17, 2022

@wallace11 @zilexa you need to teach the plugsy container how to get to its containers hostname. (I think it derives it by looking at the initial page load request headers to discover its domain name)

Internally Plugsy is a NextJs app with server side api routes (this part is important), these routes fire off Apollo GQL queries to the Plugsy Agent Instance. The agent could be another container or the same plugsy container (the default).

Because the request happens server side and not clientside, it means that your host machine is not the first port of call for resolving the hostname of your plugsy instance, instead its the hostname resolution mechanics inside the container, so probaby something like resolvconfd.

Judging by your Homeserver repo, I presume you don't have your Adguard/unbind DNS server as the authoritive DNS server for your LAN? or have your Docker host daemon setup to use that DNS server?

In my case, I have a similar setup to you except:

  • My whole server is provisioned by Ansible.
  • The services are separate DockerCompose files driven by SystemD unitfiles.
  • I use Traefik instead of Caddy
  • I don't use unbind, only Adgaurd (also for its DNS Rewrite so i get *.home.lan)
  • My router forces all devices on my lan to have the Adguard DNS server as their only dns server.

But with this setup, I still ran into this problem. (I had presumed that my dockerhost would be forced to resolve hostnames using the adguard instance it ran... 😢 )

The workaround (which is pretty robust) looks like this:

version: "3.3"

services:
  plugsy:
    restart: unless-stopped
    image: plugsy/core
    volumes:
      - ./config.json:/config.json
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      traefik.http.routers.piehole-ui-router.service: plugsy-ui-service
      traefik.http.routers.plugsy-ui-router.rule: Host(`the.home.lan`)          👀  
      traefik.http.services.plugsy-ui-service.loadbalancer.server.port: 3000
      plugsy.name: "Plugsy"
      plugsy.category: "Services"
      plugsy.icon: "@styled-icons/material-twotone/Dashboard"

    extra_hosts:
      - the.home.lan:host-gateway                                               🎉 

networks:
  default:
    external:
      name: traefik_proxy

whatever domain name you proxy plugsy under, you need to teach the container that domain name:

    extra_hosts:
      - the.home.lan:host-gateway   

host-gateway is a special domain that all containers get (if you're on docker v20.07.x+):

Older instances of docker would get some other variant of this special hostname depending on how you run docker (via docker-desktop or directly on linux):

Hope this helps.

edit: And if you're like me and tried to just dump the Dracula theme file into the config.json.... you'll get another error. you just need to give it a docker connecter:

{
    "$schema": "https://github.com/plugsy/core/releases/download/v7.0.0/core-config-schema.json",
    "connectors": [ 
      {
        "type": "DOCKER",
        "config": {}
      }
    ]
}

@Inlustra There's nothing you can do to fix this in your code. It's solved by documentation.

@zilexa
Copy link

zilexa commented Jul 18, 2022

Thanks so much @airtonix ! I have added it to my Homeserver Guide docker-compose and it works now 👯

@Inlustra please update documentation and feel free to close this one :) https://github.com/plugsy/core#usage

@Inlustra
Copy link
Collaborator

Inlustra commented Oct 11, 2022 via email

@zilexa
Copy link

zilexa commented Oct 11, 2022

I do not expose Plugsy to the web. No need for it.
Only the services that really need to are exposed: 1) Filerun, my filecloud, so that I can always access my files and smartphones can sync backups/photos 2) Vaultwarden (bitwarden) password manager 3) Firefox Sync Server 4) Guacamole RDP/remote desktop service.

All other stuff is not exposed. I also run Wireguard server and have configured my phones to automatically connect to my home VPN when I leave my home WiFi, but only for DNS and the LAN ip range. This way, I can still have access to all my local services through VPN.

From security and confidentiality perspective, I believe this is best, to only expose what is necessary.

So now I can always access plugsy by going to http://g.o :) Either via LAN or through VPN, but I don't even notice the connection type.

@gueldenstone
Copy link

gueldenstone commented Oct 21, 2022

Hmm. I followed @airtonix suggestion and added the domain to extra_hosts but this does not work for me.

My setup:
I run everything behind a traefik reverse proxy configured with labels. I only allow https on traefik. Http get redirected.

My docker-compose gets rendered as a template by ansible so there are some jinja2 varirables in there. Replace role_name with plugsy and domain with any domain like sub.example.com.

version: '3'

services:
  plugsy:
    image: plugsy/core:latest
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "{{ docker_dir.path }}/config.json:/config.json"
    restart: unless-stopped
    labels:
      - traefik.enable=true
      - traefik.http.routers.{{ role_name }}.rule=Host(`{{ domain }}`)
      - traefik.http.routers.{{ role_name }}.entrypoints=https
      - traefik.http.routers.{{ role_name }}.tls=true
      - traefik.http.routers.{{ role_name }}.tls.certresolver=letsencrypt
      - traefik.http.services.{{ role_name }}.loadbalancer.server.port=3000
      - traefik.http.routers.{{ role_name }}.middlewares=adminauth
 
    networks:
      - web
    extra_hosts:
      - "{{ domain }}:host-gateway"
networks:
  web:
    external:
      name: traefik_web

And here the logs

lugsy_1  | ApolloError: Unexpected token U in JSON at position 4
plugsy_1  |     at new ApolloError (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/errors/errors.cjs.js:31:28)
plugsy_1  |     at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/core/core.cjs.js:1493:19
plugsy_1  |     at both (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:963:53)
plugsy_1  |     at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:72
plugsy_1  |     at new Promise (<anonymous>)
plugsy_1  |     at Object.then (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:956:24)
plugsy_1  |     at Object.error (/opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/utilities/utilities.cjs.js:964:49)
plugsy_1  |     at notifySubscription (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:140:18)
plugsy_1  |     at onNotify (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:179:3)
plugsy_1  |     at SubscriptionObserver.error (/opt/prod/.yarn/cache/zen-observable-npm-0.8.15-3bec99c19c-7d155f8a75.zip/node_modules/zen-observable/lib/Observable.js:240:7) {
plugsy_1  |   graphQLErrors: [],
plugsy_1  |   networkError: SyntaxError [ServerParseError]: Unexpected token U in JSON at position 4
plugsy_1  |       at JSON.parse (<anonymous>)
plugsy_1  |       at /opt/prod/.yarn/$$virtual/@apollo-client-virtual-2d6f82d6c7/0/cache/@apollo-client-npm-3.3.21-b0c859aa0b-23237e379b.zip/node_modules/@apollo/client/link/http/http.cjs.js:18:25
plugsy_1  |       at processTicksAndRejections (internal/process/task_queues.js:95:5) {
plugsy_1  |     response: Response {
plugsy_1  |       size: 0,
plugsy_1  |       timeout: 0,
plugsy_1  |       [Symbol(Body internals)]: [Object],
plugsy_1  |       [Symbol(Response internals)]: [Object]
plugsy_1  |     },
plugsy_1  |     statusCode: 401,
plugsy_1  |     bodyText: '401 Unauthorized\n'
plugsy_1  |   },
plugsy_1  |   extraInfo: undefined
plugsy_1  | }

maybe someone has an idea of what i'm doing wrong?

@zilexa
Copy link

zilexa commented Oct 22, 2022

The suggestion was for Caddy. Not Traefik.

Also be aware this project is stale. This might be a much better alternative: https://github.com/Lissy93/dashy

@frob
Copy link

frob commented Mar 6, 2024

In Traefik the bug comes from the authentication middleware. I expect the middleware is some sort of basic auth.

@frob
Copy link

frob commented Mar 6, 2024

I expect it has something to do with the URL parsing in this file. https://github.com/plugsy/core/blob/main/packages/core/lib/apollo/links/index.ts

Likely line 16 uri: ${scheme}://${location.host}/graphql,
My guess is location.host no longer holds what it is expected to hold once basic auth is in the mix. Remember that basic auth is passed as a part of the URL for example https://username:password@example.com would be the fully qualified basic authenticated URL for https://example.com with username for username and password as password.

@frob
Copy link

frob commented Mar 13, 2024

Looking into this a bit further, the issue might be that it is trying access it's own apis over the server side which is being blocked by the auth layer of the reverse proxy. In my case I would need to setup traefik to accept it's own requests unchallenged. Probably with a custom router.

@zilexa
Copy link

zilexa commented Mar 17, 2024

The solution suggested above when using Caddy as reverse proxy still works just fine..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants