ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.21k stars 117 forks source link

SSL / TLS #667

Open codenamegary opened 1 year ago

codenamegary commented 1 year ago

The problem I am facing I have this up and running and it works great! I'm facing challenges when serving up something over SSL, and then trying to connect to wss:// in production. Browsers throw mixed content errors and it doesn't work.

The solution I would like

const server = Server.configure({
  port: 3333,
  address: address(),
  async onConnect(data) {
    console.log(Date.now() + ' connected!')
  },
  extensions: [
    new SQLite({
      database: 'db.sqlite',
    })
  ],
  // New stuff here
  ssl: {
    cert: "/path/to/certificate.pem",
    keyPath: "/path/to/key.pem"
  }
})

And essentially just follow along the ws example from there.

Alternatives I have considered I have tried every AWS load balancer config and an nginx proxy but nothing seems to work.

Additional context I think I have a handle on how this could work, happy to put together a pull request if it's desireable.

codenamegary commented 1 year ago

I managed to get this working but I'm not proud of my methods. Used a combination of local-ssl-proxy and certbot. 😂😭

jimmiebtlr commented 1 year ago

Not sure about the SSL flags, but to be sure, you meant 'wss://' not 'ws://' for secure websockets correct?

codenamegary commented 1 year ago

Yep that's right. Updated.

markcipolla commented 11 months ago

@codenamegary Mind sharing how you created a workaround? I'm having the same issue

codenamegary commented 9 months ago

@markcipolla - Sorry for the super late response. My workaround was just to use this.

https://github.com/cameronhunter/local-ssl-proxy

I used certbot to generate a certificate then just run local-ssl-proxy accordingly to forward from 443 to whatever port my HocusPocus is running on.

csaeth commented 9 months ago

Hi @codenamegary,

Thanks for sharing your solution. Are you using HocuspocusProvider or a custom Provider (y-websocket) to connect to the HocusPocus Server via local-ssl-proxy?

Cheers!

codenamegary commented 9 months ago

I'm using HocuspocusProvider.