Move SSL to proxy so we don't need sudo for backend

This commit is contained in:
Anthony Wang 2022-01-12 14:36:59 -06:00
parent 63b522b6d2
commit f4d4d16b87
Signed by: a
GPG key ID: BC96B00AEC5F2D76
3 changed files with 5 additions and 8 deletions

View file

@ -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']}});*/

5
env
View file

@ -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

2
run
View file

@ -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