From f4d4d16b87272c728a138475659d9c5f67ecd090 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Wed, 12 Jan 2022 14:36:59 -0600 Subject: [PATCH] Move SSL to proxy so we don't need sudo for backend --- back/src/server.ts | 6 +++--- env | 5 +---- run | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/back/src/server.ts b/back/src/server.ts index fca32d1..c73162a 100644 --- a/back/src/server.ts +++ b/back/src/server.ts @@ -3,9 +3,9 @@ import http from 'http'; import https from 'https'; import {Server} from 'socket.io'; -// export default new Server({cors: {origin: process.env.ORIGIN, methods: ['GET', 'POST']}}); +export default new Server({cors: {origin: process.env.ORIGIN, methods: ['GET', 'POST']}}); -const base = process.env.SSL_KEY && process.env.SSL_CERT && process.env.SSL_CA ? https.createServer({ +/*const base = process.env.SSL_KEY && process.env.SSL_CERT && process.env.SSL_CA ? https.createServer({ "key": fs.readFileSync(process.env.SSL_KEY), "cert": fs.readFileSync(process.env.SSL_CERT), "ca": fs.readFileSync(process.env.SSL_CA) @@ -14,4 +14,4 @@ base.listen(+process.env.PORT!, '0.0.0.0', () => { console.log(`Listening on port ${process.env.PORT}`); }); -export default new Server(base, {cors: {origin: process.env.ORIGIN, methods: ['GET', 'POST']}}); +export default new Server(base, {cors: {origin: process.env.ORIGIN, methods: ['GET', 'POST']}});*/ diff --git a/env b/env index 579c9a7..a55a157 100644 --- a/env +++ b/env @@ -1,6 +1,3 @@ export NEXT_PUBLIC_BACK_HOST='https://server.exozy.me' export ORIGIN="*" -export PORT=6001 -export SSL_KEY=/etc/letsencrypt/live/exozy.me/privkey.pem -export SSL_CERT=/etc/letsencrypt/live/exozy.me/cert.pem -export SSL_CA=/etc/letsencrypt/live/exozy.me/chain.pem +export PORT=6000 diff --git a/run b/run index 4a20c1f..7ce0311 100755 --- a/run +++ b/run @@ -2,4 +2,4 @@ source ./env ./build cd front -npm run start -- -p 5000 | sudo -E node ../back/dist/index.js # sudo hack to read SSL files +npm run start -- -p 5000 | node ../back/dist/index.js