commit
This commit is contained in:
parent
7d70b0bfb5
commit
7b84ceec5d
5 changed files with 19 additions and 1384 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,5 +1,3 @@
|
|||
/node_modules
|
||||
.env
|
||||
package-lock.json
|
||||
sslcert/privkey.pem
|
||||
sslcert/fullchain.pem
|
||||
package-lock.json
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"port": 3000
|
||||
}
|
|
@ -6,7 +6,19 @@ services:
|
|||
network: host
|
||||
restart: always
|
||||
image: joclud_api
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "443:443"
|
||||
container_name: joclud_api
|
||||
expose:
|
||||
- 80
|
||||
networks:
|
||||
- traefik
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.joclud.rule=Host(`api.joclud.leizour.fr`)"
|
||||
- "traefik.http.routers.joclud.entrypoints=websecure"
|
||||
- "traefik.http.routers.joclud.tls=true"
|
||||
- "traefik.http.routers.joclud.tls.certresolver=myresolver"
|
||||
- "traefik.http.services.joclud.loadbalancer.server.port=80"
|
||||
container_name: joclud_api
|
||||
|
||||
networks:
|
||||
traefik:
|
||||
external: true
|
16
index.js
16
index.js
|
@ -8,7 +8,6 @@ const https = require("https");
|
|||
require("dotenv").config();
|
||||
|
||||
const app = express();
|
||||
const port = config.port || 3000;
|
||||
|
||||
app.use(express.json());
|
||||
app.use(cookieParser());
|
||||
|
@ -34,17 +33,6 @@ function loadRoutes(folderName) {
|
|||
|
||||
loadRoutes("api");
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server listening on http://localhost:${port}/`);
|
||||
app.listen(80, () => {
|
||||
console.log(`Server listening on http://localhost:80/`);
|
||||
});
|
||||
|
||||
const privateKey = fs.readFileSync("./sslcert/privkey.pem", "utf8");
|
||||
const certificate = fs.readFileSync("./sslcert/fullchain.pem", "utf8");
|
||||
|
||||
const credentials = { key: privateKey, cert: certificate };
|
||||
|
||||
const httpsServer = https.createServer(credentials, app);
|
||||
|
||||
httpsServer.listen(443, () => {
|
||||
console.log("https server listening on port 443")
|
||||
})
|
1360
package-lock.json
generated
1360
package-lock.json
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue