snapdrop

A Progressive Web App for local file sharing
git clone http://git.hanabi.in/repos/snapdrop.git
Log | Files | Refs | README | LICENSE

commit f418dc26b8f56afb27306ff3d9a9b7ebb7b5c4fb
parent 993b48439611a0594c2d6980ccad5172cb67560e
Author: pa7ryk <patryk.jozwiak@outlook.com>
Date:   Thu, 13 Jun 2019 16:47:25 +0200

Integrates docker.

Diffstat:
MREADME.md | 18++++++------------
Mclient/scripts/network.js | 3+--
Adocker-compose.yml | 16++++++++++++++++
Dnginx.conf.example | 60------------------------------------------------------------
Anginx/default.conf | 30++++++++++++++++++++++++++++++
5 files changed, 53 insertions(+), 74 deletions(-)

diff --git a/README.md b/README.md @@ -43,21 +43,15 @@ ShareDrop uses WebRTC only and isn't compatible with Safari browsers. Snapdrop u * Do security analysis and suggestions ## Local Development +[Install docker with docker-compose.](https://docs.docker.com/compose/install/) + ``` - git clone git@github.com:RobinLinus/snapdrop.git - cd snapdrop/server - npm install - node index.js - - # open a second shell: - cd snapdrop/client - # Python 2 - python -m SimpleHTTPServer - # Python 3 - python3 -m http.server + git clone git@github.com:pa7ryk/snapdrop.git + cd snapdrop + docker-compose up ``` -Now point your browser to http://localhost:8000. +Now point your browser to http://localhost:8080.     ## Deployment Notes The client expects the server at http(s)://your.domain/server. diff --git a/client/scripts/network.js b/client/scripts/network.js @@ -54,9 +54,8 @@ class ServerConnection { _endpoint() { // hack to detect if deployment or development environment const protocol = location.protocol.startsWith('https') ? 'wss' : 'ws'; - const host = location.hostname.startsWith('localhost') ? 'localhost:3000' : (location.host + '/server'); const webrtc = window.isRtcSupported ? '/webrtc' : '/fallback'; - const url = protocol + '://' + host + webrtc; + const url = protocol + '://' + location.host + '/server' + webrtc; return url; } diff --git a/docker-compose.yml b/docker-compose.yml @@ -0,0 +1,16 @@ +version: "3" +services: + node: + image: "node:lts-alpine" + user: "node" + working_dir: /home/node/app + volumes: + - ./server/:/home/node/app + command: ash -c "npm i && node index.js" + nginx: + image: "nginx:alpine" + volumes: + - ./client:/usr/share/nginx/html + - ./nginx/default.conf:/etc/nginx/conf.d/default.conf + ports: + - "8080:80" diff --git a/nginx.conf.example b/nginx.conf.example @@ -1,60 +0,0 @@ -# This is an configuration example. Please adjust to fit your environment (especially root location and server_name). -# The nginx user requires read permissions to the root location. - -user nginx; -worker_processes auto; -error_log /var/log/nginx/error.log; -pid /run/nginx.pid; - -# Load dynamic modules. See /usr/share/nginx/README.dynamic. -include /usr/share/nginx/modules/*.conf; - -events { - worker_connections 1024; -} - -http { - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - # Load modular configuration files from the /etc/nginx/conf.d directory. - # See http://nginx.org/en/docs/ngx_core_module.html#include - # for more information. - include /etc/nginx/conf.d/*.conf; - - server { - server_name your.domain; - root /path/to/snapdrop/client; - - # Load configuration files for the default server block. - include /etc/nginx/default.d/*.conf; - - location /server { - proxy_pass http://localhost:3000/; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header X-Forwarded-For $remote_addr; - } - - location / { - proxy_http_version 1.1; - } - - - listen [::]:80 ; - listen 80 ; -} -} diff --git a/nginx/default.conf b/nginx/default.conf @@ -0,0 +1,30 @@ +server { + listen 80; + #server_name your.domain; + + #charset koi8-r; + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location /server { + proxy_connect_timeout 300; + proxy_pass http://node:3000; + proxy_set_header Connection "upgrade"; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header X-Forwarded-for $remote_addr; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} +