mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-23 08:16:19 -04:00
commit
efa4d68103
5 changed files with 53 additions and 74 deletions
18
README.md
18
README.md
|
@ -43,21 +43,15 @@ ShareDrop uses WebRTC only and isn't compatible with Safari browsers. Snapdrop u
|
||||||
* Do security analysis and suggestions
|
* Do security analysis and suggestions
|
||||||
|
|
||||||
## Local Development
|
## Local Development
|
||||||
|
[Install docker with docker-compose.](https://docs.docker.com/compose/install/)
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone git@github.com:RobinLinus/snapdrop.git
|
git clone git@github.com:RobinLinus/snapdrop.git
|
||||||
cd snapdrop/server
|
cd snapdrop
|
||||||
npm install
|
docker-compose up
|
||||||
node index.js
|
|
||||||
|
|
||||||
# open a second shell:
|
|
||||||
cd snapdrop/client
|
|
||||||
# Python 2
|
|
||||||
python -m SimpleHTTPServer
|
|
||||||
# Python 3
|
|
||||||
python3 -m http.server
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Now point your browser to http://localhost:8000.
|
Now point your browser to http://localhost:8080.
|
||||||
|
|
||||||
## Deployment Notes
|
## Deployment Notes
|
||||||
The client expects the server at http(s)://your.domain/server.
|
The client expects the server at http(s)://your.domain/server.
|
||||||
|
@ -66,7 +60,7 @@ When serving the node server behind a proxy the `X-Forwarded-For` header has to
|
||||||
|
|
||||||
By default the server listens on port 3000.
|
By default the server listens on port 3000.
|
||||||
|
|
||||||
For an nginx configuration example see `nginx.conf.example`.
|
For an nginx configuration example see `nginx/default.conf`.
|
||||||
|
|
||||||
## Licences
|
## Licences
|
||||||
* Thanks to [Mark DiAngelo]() for the [Blop Sound](http://soundbible.com/2067-Blop.html)
|
* Thanks to [Mark DiAngelo]() for the [Blop Sound](http://soundbible.com/2067-Blop.html)
|
||||||
|
|
|
@ -54,9 +54,8 @@ class ServerConnection {
|
||||||
_endpoint() {
|
_endpoint() {
|
||||||
// hack to detect if deployment or development environment
|
// hack to detect if deployment or development environment
|
||||||
const protocol = location.protocol.startsWith('https') ? 'wss' : 'ws';
|
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 webrtc = window.isRtcSupported ? '/webrtc' : '/fallback';
|
||||||
const url = protocol + '://' + host + webrtc;
|
const url = protocol + '://' + location.host + '/server' + webrtc;
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
|
@ -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"
|
|
@ -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 ;
|
|
||||||
}
|
|
||||||
}
|
|
30
nginx/default.conf
Normal file
30
nginx/default.conf
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue