1.2.0 • Published 4 years ago

ezproxy v1.2.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

ezproxy

This is design to be a cookie cutter proxy server ready to go. If you need detail on how to use http-proxy-middleware, please visit http-proxy-middleware. Shelljs and dotenv is loaded for your convenience.

Example: Proxy for API

Copy and Paste

const express = require('express')
const dotenv = require('dotenv').config();
const app = express()
const path = require('path')
const { createProxyMiddleware } = require('http-proxy-middleware')
const username = process.env.ID
const target = createProxyMiddleware(
                                      {target: 'server URL and port', ChangeOrigin: true, auth: username, loglevel: 'debug' }

)

app.use('Local server URI like /data/api', target); 


app.use(express.static('public'))

app.get('/', function(req, res){
                                res.sendFile(path.resolve(__dirname, 'html file to be send to user for example index.html'))

} )

 app.listen(3001)

Go to each of these line and just change the variable

Use to hide the username and password

const username = process.env.ID

Change the target to url

const target = createProxyMiddleware(
         {target: 'server URL and port', ChangeOrigin: true, auth: username, loglevel: 'debug' }  
)

Change the URI to what you want

app.use('Local server URI like /data/api', target);\

Create a public folder

app.use(express.static('public'))

Change the file name

app.get('/', function(req, res){
                                res.sendFile(path.resolve(__dirname, 'html file to be send to user for example index.html')) 

} )

Change the port number

 app.listen(3001) 

Example: web proxy

Copy and Paste

const http = require('http');
const connect = require('connect');
const { createProxyMiddleware } = require('http-proxy-middleware')
const app = connect();
const site = createProxyMiddleware({target: 'server URL and port', changeOrigin: true, logLevel: 'debug'});

app.use('/', site);


http.createServer(app).listen(3005);

Change the target to url

const site = createProxyMiddleware({target: 'server URL and port', changeOrigin: true, logLevel: 'debug'});
1.2.0

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago