如果已有nginx,可以不要docker里的,合并部署到自己的nginx:
#docker-compose.yml参考
version: "3"
services:
node:
container_name: snapdrop
image: "node:lts-alpine"
working_dir: /home/node/app
restart: always
volumes:
- ./server/:/home/node/app
ports:
- "127.0.0.1:3000:3000"
command: ash -c "npm i && node index.js"
#nginx.conf参考
server {
listen 0.0.0.0:443 ssl http2;
ssl_certificate /xxx/xxx.cer;
ssl_certificate_key /xxx/xxx.key;
server_name xxx;
access_log log/xxx.log main;
error_log log/xxx.error.log;
expires epoch;
location / {
root /xxx/client;
index index.html index.htm;
}
location /server {
proxy_connect_timeout 300;
proxy_pass http://127.0.0.1:3000;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-for $remote_addr;
}
location /ca.crt {
alias /xxx/docker/certs/snapdropCA.crt;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /xxx/client;
}
}