Skip to content

Commit 6bcbd45

Browse files
committed
v1.0.0
1 parent bd6d10d commit 6bcbd45

File tree

11 files changed

+494
-1
lines changed

11 files changed

+494
-1
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
custom: https://www.paypal.me/kyberneees
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/custom.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Custom issue template
3+
about: Describe this issue template's purpose here.
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Have you contributed with at least a little donation to support the development of this project?**
11+
- Paypal: https://www.paypal.me/kyberneees
12+
- [TRON](https://www.binance.com/en/buy-TRON) Wallet: `TJ5Bbf9v4kpptnRsePXYDvnYcYrS5Tyxus`
13+
14+
**Is your feature request related to a problem? Please describe.**
15+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
16+
17+
**Describe the solution you'd like**
18+
A clear and concise description of what you want to happen.
19+
20+
**Describe alternatives you've considered**
21+
A clear and concise description of any alternative solutions or features you've considered.
22+
23+
**Additional context**
24+
Add any other context or screenshots about the feature request here.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
name: 'build images'
3+
4+
on:
5+
release:
6+
types: [published]
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
docker:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Prepare
19+
id: prep
20+
run: |
21+
DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/}
22+
VERSION=latest
23+
# SHORTREF=${GITHUB_SHA::8}
24+
25+
# If this is git tag, use the tag name as a docker tag
26+
if [[ $GITHUB_REF == refs/tags/* ]];
27+
then
28+
VERSION=${GITHUB_REF#refs/tags/v}
29+
TAGS="${DOCKER_IMAGE}:${VERSION}-alpine"
30+
else
31+
TAGS="${DOCKER_IMAGE}:latest"
32+
fi
33+
34+
# Set output parameters.
35+
echo ::set-output name=tags::${TAGS}
36+
echo ::set-output name=docker_image::${DOCKER_IMAGE}
37+
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@master
40+
with:
41+
platforms: all
42+
43+
- name: Set up Docker Buildx
44+
id: buildx
45+
uses: docker/setup-buildx-action@master
46+
47+
- name: Login to DockerHub
48+
if: github.event_name != 'pull_request'
49+
uses: docker/login-action@v1
50+
with:
51+
username: ${{ secrets.DOCKER_USERNAME }}
52+
password: ${{ secrets.DOCKER_PASSWORD }}
53+
54+
- name: Build
55+
uses: docker/build-push-action@v2
56+
with:
57+
builder: ${{ steps.buildx.outputs.name }}
58+
context: .
59+
file: ./Dockerfile
60+
platforms: linux/amd64,linux/arm64,linux/ppc64le
61+
push: true
62+
tags: ${{ steps.prep.outputs.tags }}

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:16-alpine
2+
RUN apk add --no-cache tini
3+
4+
RUN mkdir /rproxy
5+
WORKDIR /rproxy
6+
7+
COPY package.json .
8+
COPY index.js .
9+
COPY src ./src
10+
11+
RUN npm install --production
12+
13+
ENTRYPOINT ["/sbin/tini", "--"]
14+
CMD ["node", "index.js"]

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
11
# rproxy
2-
HTTP reverse proxy implementation based on Node.js and Docker
2+
HTTP reverse proxy implementation based on Node.js and Docker.
3+
4+
`rproxy` is based on `fast-gateway` and is a ready to use Docker container image for implementing reverse proxies or API Gateways.
5+
> See: https://github.com/BackendStack21/fast-gateway
6+
7+
8+
## Usage
9+
10+
### config.js
11+
```js
12+
module.exports = {
13+
14+
middlewares: [
15+
require('cors')()
16+
],
17+
18+
routes: [{
19+
prefix: '/api',
20+
target: 'https://httpbin.org'
21+
}]
22+
23+
}
24+
```
25+
26+
### Dockerfile
27+
```Dockerfile
28+
FROM kyberneees/rproxy:latest
29+
COPY config.js ./src
30+
```
31+
32+
## Configuration
33+
### Environment values
34+
- `PORT`: Indicates the running port of the HTTP server. Defaults to: `8080`
35+
36+
### Installing custom NPM modules
37+
In order to use custom NPM modules, those have to be installed through your `Dockerfile`. For example:
38+
39+
```Dockerfile
40+
FROM kyberneees/rproxy:latest
41+
42+
RUN npm i morgan
43+
```
44+
45+
Modules installed by default:
46+
- cors: https://www.npmjs.com/package/cors
47+
- http-cache-middleware: https://www.npmjs.com/package/http-cache-middleware

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict'
2+
3+
const gateway = require('fast-gateway')
4+
const PORT = process.env.PORT || 8080
5+
6+
const proxy = gateway(require('./src/config'))
7+
proxy.start(PORT).then(() => {
8+
console.log(`Proxy server listening on port ${PORT}`)
9+
})

0 commit comments

Comments
 (0)