Skip to content

Commit

Permalink
Merge pull request #10 from RuiSiang/dockerize
Browse files Browse the repository at this point in the history
Dockerize
  • Loading branch information
RuiSiang authored Mar 12, 2021
2 parents a13c1ab + 1a33241 commit ebd7441
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
npm-debug.log
npm-error.log
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SESSION_KEY='abcdefghijklmnop'
PORT=3000
SESSION_KEY="abcdefghijklmnop"
WAF=on
POW=on
NONCE_VALIDITY=60000
INITIAL_DIFFICULTY=13
BACKEND_URL='http://example.com'
BACKEND_URL="http://example.com"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Compose File
docker-compose.yaml
# Logs
logs
*.log
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:12
WORKDIR /usr/src/pow-shield
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE ${PORT}
CMD [ "node", "dist/bin/server.js" ]
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,38 @@ github repo
```
# clone repo first
npm install
cp .env.example .env
cp -n .env.example .env
# edit .env
npm run build
npm start
```
dockerhub (work in progress)
docker run
```
docker run -p 3000:3000 -e BACKEND_URL="http://example.com" -d ruisiang/pow-shield
```
docker-compose
```
see docker-compose.example.yaml
```

## Configuration
+ PORT: port that PoW Shield listens to
+ SESSION_KEY: secret key for cookie signatures, use a unique one for security reasons, or anyone can forge your signed cookies
+ WAF: toggles waf functionality on/off (waf is a work in progress)
+ POW: toggles PoW functionality on/off (if not temporary switched off, why use this project at all?)
+ NONCE_VALIDITY: specifies the maximum time a nonce has to be submitted to the server after generation(used to enforce difficulty change and filter out stale nonces)
+ INITIAL_DIFFICULTY: initial difficulty, number of leading 0-bits in produced hash (0:extremely easy ~ 256:impossible, 13(default):takes about 5 seconds for the browser to calculate)
+ BACKEND_URL: location to proxy authenticated traffic to, IP and URLs are both accepted
+ BACKEND_URL: location to proxy authenticated traffic to, IP and URLs are both accepted(accepts protocol://url(:port) or protocol://ip(:port))

## TODOs
- [x] Web Service Structure
- [x] Proxy Functionality
- [x] PoW Implementation
- [x] Dockerization
- [ ] WAF Implementation
- [ ] IP Blacklisting
- [ ] Dynamic Difficulty
- [ ] Unit Testing
- [ ] Dockerization
- [ ] Multi-Instance Syncing

## License
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.4'

services:
pow-shield:
image: ruisiang/pow-shield
environment:
- PORT=3000
- SESSION_KEY="abcdefghijklmnop"
- WAF=on
- POW=on
- NONCE_VALIDITY=60000
- INITIAL_DIFFICULTY=13
- BACKEND_URL="http://example.com"
expose:
- '3000'
ports:
- '3000:3000'

0 comments on commit ebd7441

Please sign in to comment.