qownnotes / web-app

QOwnNotes Web App
GNU Affero General Public License v3.0
7 stars 4 forks source link

Self hosting does not work. #1

Closed gerroon closed 3 years ago

gerroon commented 3 years ago

Hi

Thanks for this Docker setup.

I am running this inside my LAN , the server is 192.168.2.10 . I set it up (very easty) I put the address of this pod into QownNotes web app option as wss://192.168.2.10:9000 I make sure the I use the security token from Qown's web app panel in the settings.

compose file

version: "3.1"

services:
  web:
    image: img-qownnotes-web-app
    build: .
    ports:
      - "9000:8080"
    environment:
      - TZ=Europe/Vienna

Then I open 192.168.2.10:9000 in the browser and try to upload a photo. The js console prints these

We did not get a file insert confirmation after 15sec. Is the QOwnNotes desktop application running and using the same security token?

Connection to socket ws://localhost:8080/ws/xxK42rkG7FUvtVhb68R9TTtnt8kYHAxx closed
WebSocketService.js:16 Connecting to socket ws://localhost:8080/ws/xxK42rkG7FUvtVhb68R9TTtnt8kYHAxx
WebSocketService.js:18 WebSocket connection to 'ws://localhost:8080/ws/xxK42rkG7FUvtVhb68R9TTtnt8kYHAxx' failed: 
value @ WebSocketService.js:18
value @ SendFilesService.js:6
(anonymous) @ SendFilesService.js:12
WebSocketService.js:29 undefined
window.ws.onerror @ WebSocketService.js:29
error (async)
value @ WebSocketService.js:28
value @ SendFilesService.js:6
(anonymous) @ SendFilesService.js:12
setTimeout (async)
value @ SendFilesService.js:12
(anonymous) @ SendFilesService.js:12
pbek commented 3 years ago
  - "9000:8080"

You are exposing the app on port 9000...

WebSocketService.js:18 WebSocket connection to 'ws://localhost:8080/ws/xxK42rkG7FUvtVhb68R9TTtnt8kYHAxx' failed:

... not 8080.

gerroon commented 3 years ago

Sure, because 8080 is already taken by another server app.

pbek commented 3 years ago

Can you please post the output from the debug settings that you can copy when you get into the settings dialog in QOwnNotes and head over to the Debug section of it.

pbek commented 3 years ago

Or are you talking about the local connection? For local development (via http) the port in the web-application is hard-coded to 8080 in the web part of the service since the web part and the Go part are running on different ports.

https://github.com/qownnotes/web-app/blob/dac4bf47107af65e8bfd744f519b6e8ee675852d/web/src/services/WebSocketService.js#L11-L15

If you really want to host the service yourself you are supposed to use it behind a reverse proxy (e.g. https://traefik.io/) for TLS termination.

For me that docker-compose.yml configuration looks like this:

  qownnotes-web-app:
    image: pbeke/qownnotes-web-app
    restart: always
    networks:
      - traefik
    labels:
      - traefik.http.routers.qownnotes-web-app.rule=Host(`app.qownnotes.org`)
      - traefik.http.routers.qownnotes-web-app.tls.certresolver=default
      - traefik.http.routers.qownnotes-web-app.tls=true
      - traefik.http.services.qownnotes-web-app.loadbalancer.server.port=8080
    environment:
      - TZ=Europe/Vienna
gerroon commented 3 years ago

Thanks that makes sense, I was assuming that I did not need to reverse proxy it.

pbek commented 3 years ago

The whole reason for the web-app was to not have to be in the same network (like for example the QOwnNotes browser extension) for the communication between the web-app and QOwnNotes... And you need transport security if you are talking over the internet. 😉

pbek commented 3 years ago

I'll close this then...

pbek commented 3 years ago

If you need a good docker middleware for TLS termination you can try https://doc.traefik.io/traefik/v2.0/https/tls/.

pbek commented 3 years ago

If no default certificate is provided, Traefik generates and uses a self-signed certificate (ok for local use). Of course I'm using Let's Encrypt on my remote server, Traefik handles that too.