8000 Using with local nextcloud setup · Issue #20 · strukturag/pdfdraw · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Using with local nextcloud setup #20

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

Closed
Querela opened this issue Feb 22, 2021 · 2 comments
Closed

Using with local nextcloud setup #20

Querela opened this issue Feb 22, 2021 · 2 comments

Comments

@Querela
Copy link
Querela commented Feb 22, 2021

Hi, looking for some help.
Trying to get it to work with a local nextcloud instance (localhost) seems not to work. I'm not sure whether nextcloud has to be served via SSL or requires an extra domain but I could not get it to save my annotation because the communication from the pdfdraw-server to the nextcloud api failed.

nextcloud: localhost:8080
pdfdraw-server: localhost:8081

My docker-compose.yml

Nexcloud app configuration:
-> secret: test-key
-> host: http://localhost:8081

version: '2'

volumes:
nextcloud-files:
mysql-files:

services:
db:
  container_name: nextcloud-db
  image: mariadb
  restart: always
  command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
  volumes:
    - mysql-files:/var/lib/mysql
  environment:
    - MYSQL_ROOT_PASSWORD=admin
    - MYSQL_PASSWORD=nextcloud
    - MYSQL_DATABASE=nextcloud
    - MYSQL_USER=nextcloud

# redis:
#   container_name: nextcloud-redis
#   image: redis:alpine
#   restart: always

app:
  container_name: nextcloud-app
  image: nextcloud:19
  #image: nextcloud:20-rc
  restart: always
  ports:
    - 8080:80
  links:
    - db
    # - redis
    # - pdfdraw-server
  volumes:
    - nextcloud-files:/var/www/html
  environment:
    - MYSQL_PASSWORD=nextcloud
    - MYSQL_DATABASE=nextcloud
    - MYSQL_USER=nextcloud
    - MYSQL_HOST=db
    # - REDIS_HOST=redis
    - NEXTCLOUD_ADMIN_USER=nextcloud
    - NEXTCLOUD_ADMIN_PASSWORD=nextcloud

pdfdraw-server:
  container_name: nextcloud-pdfdraw-backend
  build:
    context: pdfdraw/server
    dockerfile: docker/Dockerfile
  #links:
  #  - app
  environment:
    port: 8081
    secret: 'test-key'
    #allow_invalid_certificates: 1
    #use_auto_ecdh_curve: 1
    #cmd_pdftk: ''
    #cmd_svg2pdf: ''
    #network_mode: "host"

  ports:  
  - '8081:8081'
My errors
nextcloud-pdfdraw-backend | a user connected {
nextcloud-pdfdraw-backend |   token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA4MCIsI
nN1YiI6Im5leHRjbG91ZCIsImV4cCI6MTYxNDA3OTE1NCwiZmlsZSI6IjE0MiIsImZpbGVuYW1lIjoiNDBhY2ZkNDMzYzliNmRhOTVjODk3MWY4NDFmZDVmN
zZkYjEyZTFhYS0xNjExMzA1Njk5OTAzLnBkZiIsImRpc3BsYXluYW1lIjoibmV4dGNsb3VkIiwicGVybWlzc2lvbnMiOjI3fQ.G8v6oehCCoPcPcNGx4CYH5
GObyhhf__3kEQJ146flM0',
nextcloud-pdfdraw-backend |   EIO: '3',
nextcloud-pdfdraw-backend |   transport: 'websocket'
nextcloud-pdfdraw-backend | }
nextcloud-pdfdraw-backend | Token {
nextcloud-pdfdraw-backend |   iss: 'http://localhost:8080',
nextcloud-pdfdraw-backend |   sub: 'nextcloud',
nextcloud-pdfdraw-backend |   exp: 1614079154,
nextcloud-pdfdraw-backend |   file: '142',
nextcloud-pdfdraw-backend |   filename: '40acfd433c9b6da95c8971f841fd5f76db12e1aa-1611305699903.pdf',
nextcloud-pdfdraw-backend |   displayname: 'nextcloud',
nextcloud-pdfdraw-backend |   permissions: 27
nextcloud-pdfdraw-backend | }
nextcloud-pdfdraw-backend | created room 142
nextcloud-pdfdraw-backend | user joined room 142 {
nextcloud-pdfdraw-backend |   displayname: 'nextcloud',
nextcloud-pdfdraw-backend |   permissions: 27,
nextcloud-pdfdraw-backend |   userid: 'BxUcYBinabe18qE3AAAB'
nextcloud-pdfdraw-backend | }
nextcloud-pdfdraw-backend | Error receiving items {
nextcloud-pdfdraw-backend |   error: Error: connect ECONNREFUSED 127.0.0.1:8080
nextcloud-pdfdraw-backend |       at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1137:16) {
nextcloud-pdfdraw-backend |     errno: -111,
nextcloud-pdfdraw-backend |     code: 'ECONNREFUSED',
nextcloud-pdfdraw-backend |     syscall: 'connect',
nextcloud-pdfdraw-backend |     address: '127.0.0.1',
nextcloud-pdfdraw-backend |     port: 8080
nextcloud-pdfdraw-backend |   }
nextcloud-pdfdraw-backend | }

And errors while annotation/drawing (probably because of the error above):

nextcloud-pdfdraw-backend | Error receiving items {
nextcloud-pdfdraw-backend |   error: Error: write EPROTO 140583453284224:error:1408F10B:SSL routines:ssl3_get_record:wro
ng version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:
nextcloud-pdfdraw-backend |
nextcloud-pdfdraw-backend |       at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
 {
nextcloud-pdfdraw-backend |     errno: -71,
nextcloud-pdfdraw-backend |     code: 'EPROTO',
nextcloud-pdfdraw-backend |     syscall: 'write'
nextcloud-pdfdraw-backend |   }
nextcloud-pdfdraw-backend | }

I also tried splitting the nextcloud and the pdfdraw server into separate configurations but that failed more because then the localhost domain was not the same in the pdfdraw instance compared to the nextcloud one ...
For this I "fixed" the pdfdraw server code to use host.docker.internal instead of localhost for the separate docker-compose configs but this did not work/same error.

So, the socket.io communication works but all requests back to nextcloud fail.
Does it require some extra nginx configuration? Described in #16 ? But I'm not sure how exactly, as the nextcloud server is also on localhost and doesn't use SSL.

Update: same issue/error when I run the pdfdraw server locally (not in docker).
I then need to update the URL to use the docker host ip (some stackoverflow answer) to get the correct address:

export DOCKERHOST=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)
echo $DOCKERHOST

Changing config.allow_invalid_certificates and config.use_auto_ecdh_curve did not help.

@Querela
Copy link
Author
Querela commented Feb 22, 2021

What worked, replace all https.request with http.request ... Seems kinda logical for local test instance.
BUT, just running the pdfdraw server locally works. Trying to run it in a docker container fails with

nextcloud-pdfdraw | Error receiving items {
nextcloud-pdfdraw |   error: Error: connect ECONNREFUSED 127.0.0.1:8080
nextcloud-pdfdraw |       at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1137:16) {
nextcloud-pdfdraw |     errno: -111,
nextcloud-pdfdraw |     code: 'ECONNREFUSED',
nextcloud-pdfdraw |     syscall: 'connect',
nextcloud-pdfdraw |     address: '127.0.0.1',
nextcloud-pdfdraw |     port: 8080
nextcloud-pdfdraw |   }
nextcloud-pdfdraw | }

Not exactly sure why. (Well, somehow the localhost:8080 is not reachable, but substituting it with app:80 to get the correct IP fails, too.)

Not sure whether we can just include this into code, so that it looks which Token -> iss URL is returned and if it is not HTTPS it falls back to HTTP? Makes it insecure, which for local test instances might not matter, but it is definitely not for deployment, so I don't really expect it to make it into the code base.

@fancycode
Copy link
Member

If you run the different parts in separate Docker containers, 127.0.0.1 is each container itself, i.e. 127.0.0.1 on the pdfdraw-server is a different 127.0.0.1 than in app. You will have to configure a external URL as backend server URL of pdfdraw and vice versa.

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

2 participants
0