garagescript / myproxy Goto Github PK
View Code? Open in Web Editor NEWMyProxy is an application that proxies requests to other servers
Home Page: https://garagescript.github.io/myProxy
License: MIT License
MyProxy is an application that proxies requests to other servers
Home Page: https://garagescript.github.io/myProxy
License: MIT License
Should we setup ESLint for this project ?
ESLint Plugin TypeScript maybe ?
If user goes to the root path /
from the browser, they should be redirected to /admin
if there are no availableDomains. This means that they have not setup any websites yet.
Refer to this: https://github.com/garageScript/myProxy/pull/42/files
After an SSL certificate has been successfully generated for the selectedDomain, save the selectedDomain into fs under the key availableDomains
. Each domain should have the properties: (with example)
[{
domain: 'innout.life',
expiration: <output from the ssl generation>,
provider: 'dns_gd'
}]
acme service should have the following signatures:
const {renewCert} from './adapters/acme'
...
// sample inputs:
// ('*.innout.life', 'dns_gd', {GD_Key: ..., GD_Secret: ...})
renewCert(domain, service, tokens)
For now, just support acme's goDaddy's API: https://github.com/Neilpang/acme.sh/wiki/dnsapi#4-use-godaddycom-domain-api-to-automatically-issue-cert
Sample implementation of renewCert:
// file root:
const serviceMapping = {
dns_gd: ['GD_Key', 'GD_Secret']
}
const renewCert = (domain, service, tokens) => {
const envVars = (serviceMapping[service] || []).reduce( (acc, key) => {
return `${acc} ${key}=${tokens[key]}`
}, '')
execShell(`${envVars} acme.sh --issue --dns ${service} -d ${domain}`)
}
All admin apis should have a middleware to check for admin cookie.
This is insecure: #22
Look at this file as an example: https://github.com/garageScript/myProxy/pull/25/files#diff-5cd017fffa83529a9153c191c72bec05
Instead of rendering to login page though, you must return a 401 status code: https://www.restapitutorial.com/httpstatuscodes.html
After this issue: #60
We need to retrieve the list of available domains so we can surface it on the home page (to create a mapping). Therefore, we need a GET /availableDomains
will not compile / build, admin.ts.
Grouped by PR:
app.listen
should only be called if ADMIN
environment is present. If not present, app.listen
should not happen, and it should log message: 'Admin UI/API is turned off'mappings
db to find the correct port, then proxy to the port.express
server to listen to http requests on port 80. Redirect every request to https domain (make sure path and query parameters are included in the redirection).Admin app should run on port 20000
.
if no cookie, prompt for admin password. Admin password input = access to admin page.
Admin password is set up by environment variables. For example:
ADMIN=9458237 yarn start
when users run yarn setup
, the following should happen:
chmod +x ./acme/acme.sh
so that the script has execution accessyarn
api/ folder is confusing... inside we have all routes (except /admin/providers), lib/ types/ folder...
We might add a routes folder with api.ts and admin.ts and move out lib/,types into /src ?
lib and types should be in src folder
/admin
currently displays nothing. It makes more sense for /admin
to display what /admin/providers
is currently displaying. All PART 1 of issue 27 will be displayed on this page.
create views folder and setup ejs rendering template
Does it make sense for a user that not use pm2
to have this file?
I think this file should not be on Github only on the server same for deploy.sh
.
OR
We can add pm2
as dependency and change npm start
to run it ?
module.exports = {
apps: [
{
name: 'myProxy-prod',
script: './build/app.js',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env_production: {
NODE_ENV: 'production',
PORT: 3000, // Should be setup with Process.env.PORT
ADMIN: '123' // Should be setup with Process.env.ADMIN
},
},
],
}
mappings
current accept domain
, ip
, and port
. We need an additional field subdomain
. Total:
ip
port
domain
subdomain
Throw a error on the first app launch on npm run start
just after npm run setup
internal/modules/cjs/loader.js:716
throw err;
^
Error: Cannot find module '/home/dev/david/app.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:713:15)
at Function.Module._load (internal/modules/cjs/loader.js:618:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
It is currently storing subdomain value. Domain value will be loaded from different api.
Please fix this API endpoint. Its a blocker, because without availableDomains
nothing works. https://github.com/garageScript/myProxy/blob/master/src/api/admin.ts#L14
Update 9/16
POST /sslCerts
is still not creating certificates in production. Please take note of the picture below:
key
/ cert
. SSL cert generation takes > 30 seconds per cert. So if we are generating 2 certs (root and wildcard), the post request should take 60 seconds.&
. This means background, so the env variables set is not applied. I would use ;
instead.Devs should be able to call isCorrectCredentials(req.body.adminPass)
, which returns true
or false
Then refactor the function in src/app.ts
from this PR: https://github.com/garageScript/myProxy/pull/118/files
As a developer, I would like to create a mapping for available domains.
/mappings
to create a mappingAdmin UI should live at /admin/serviceHostKeys
, should display a list of keys, with 3 input boxes at the top for users to quickly create serviceHostKeys. Refer to api to see details about inputs you will need.
list of keys must be grouped by the service
key. Refer to image below:
Note on the above image.
Like the rest, service
title section should be editable like the rest of the rows. It is only deletable if there are no more keys in that service.
The more open it is, the better. MIT?
Create REST apis for serviceHostKeys
to store keys to be used for acme ssh key generation
/api/admin/serviceHostKeys
{
key: 'DNSimple_OAUTH_TOKEN',
value: 'User-Input',
service: 'dns_dnsimple'
}
PATCH, PUT, DELETE, GET should be self explanatory.
API will be used to power the UI here: #12
Providers route exposes keys and secret, so they must be hidden behind the /api/admin
route (where authentication is required).
Initial simple express app
User logs in to their GoDaddy account, finds their apiKey/secret. Copies them and paste it so that we can save it.
Example:
service: GoDaddy.
key1: API_KEY.
key2: API_SECRET.
setup
setup
button, we do 2 things:
run acme.sh script with service keys.Update theCNAME
records for the domain using the service APIs so that all requests going to the domain will go to the server running myproxy
setup
will be in the dropdown. User can type in any subdomainsCUrrently, after updating or creating, there's 0 feedback so I have no idea what happened. (is it successful?)
Rename fetch
to sendRequest
or something.
Error:
fatal: not a git repository (or any of the parent directories): .git
npm ERR! path /home/dev/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/dev/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dev/.npm/_logs/2019-08-29T15_57_10_822Z-debug.log
npm ERR! path /home/dev/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/dev/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dev/.npm/_logs/2019-08-29T15_57_11_049Z-debug.log
[PM2][ERROR] File ./scripts/prod.config.js not found
Exited with code 1
Throw an error on the first run is a bad user experience.
We should create ./data.db
on npm run setup
File does not exist, but do not worry. File will be created on first save [Error: ENOENT: no such file or directory, open './data.db'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: './data.db'
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.