diff --git a/deploy/nginx.conf.example b/deploy/nginx.conf.example new file mode 100644 index 0000000..0a17096 --- /dev/null +++ b/deploy/nginx.conf.example @@ -0,0 +1,49 @@ +# Example nginx config for oscar-web behind HTTPS. +# Adjust server_name, certificate paths, and upstream port. + +upstream oscar_web { + server 127.0.0.1:3000; + keepalive 16; +} + +server { + listen 80; + listen [::]:80; + server_name chat.example.com; + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name chat.example.com; + + ssl_certificate /etc/letsencrypt/live/chat.example.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/chat.example.com/privkey.pem; + + # Add your preferred TLS/HSTS settings. + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + + # SSE endpoint: disable buffering and allow long-lived connection. + location /api/events { + proxy_pass http://oscar_web; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Connection ''; + proxy_buffering off; + proxy_cache off; + proxy_read_timeout 1h; + } + + location / { + proxy_pass http://oscar_web; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} diff --git a/deploy/oscar-web.service.example b/deploy/oscar-web.service.example new file mode 100644 index 0000000..11e9264 --- /dev/null +++ b/deploy/oscar-web.service.example @@ -0,0 +1,25 @@ +# Example systemd unit for oscar-web. +# Copy to /etc/systemd/system/oscar-web.service and adjust paths/user. + +[Unit] +Description=Oscar Web chat client +After=network.target + +[Service] +Type=simple +User=oscar-web +Group=oscar-web +WorkingDirectory=/opt/oscar-web +EnvironmentFile=/opt/oscar-web/.env +ExecStart=/usr/bin/node --env-file=/opt/oscar-web/.env src/server.js +Restart=on-failure +RestartSec=5 +# Hardening (adjust as needed for your environment) +NoNewPrivileges=true +PrivateTmp=true +ProtectSystem=strict +ProtectHome=true +ReadWritePaths=/opt/oscar-web/data + +[Install] +WantedBy=multi-user.target