Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@lopatnov/express-reverse-proxy
Advanced tools
A back-end (Node.js) development tool to serve front-end projects with back-end reverse proxy for API. Configure a tool and serve your front-end projects
A back-end (Node.js) development tool to serve front-end projects with back-end reverse proxy for API. Configure a tool and serve your front-end projects.
npm install --save-dev @lopatnov/express-reverse-proxy
express-reverse-proxy
--config <file name>
sets server configuration fileexpress-reverse-proxy --config ./server-config.json
npx @lopatnov/express-reverse-proxy
Edit server-config.json
file
{
"port": 8080
...
}
To configure server port, edit port
variable. The default server port is 8080
.
folders
variableThe folders
is a variable to serve static files such as images, CSS files, and JavaScript files.
{
"folders": "www"
}
This configuration means that the server will serve static files from a local www
directory. The folders
variable can changed by a value of relative path like "./www", "../../my-nice-project/www" or "./project/my-front-end-files".
{
"folders": ["./www", "./mock-json", "../../images"]
}
This configuration means that the server will serve static files from multiple directories:
./www
./mock-json
../../images
{
"folders": {
"/": "dist",
"/api": "./mock-json",
"/assets": {
"/images": "./images",
"/css": "./scss/dist",
"/script": "./scripts"
}
}
}
This configuration means that the server will serve static files from multiple directories. The url path maps to this directories.
In example above you can see the next mapping:
url: /
directory: dist
url: /api
directory: ./mock-json
url: /assets/images
directory: ./images
url: /assets/css
directory: ./scss/dist
url: /assets/script
directory: ./scripts
proxy
variableThe proxy
variable intended for request redirect to 3rd-party server and getting result of this response.
{
"port": 4200,
"folders": "www",
"proxy": {
"/api": "localhost:8000"
}
}
This configuration means that the server will serve static files from a local www
directory on 4200 port with remote API on http://localhost:8000. When the web-site makes request to "/api" path, the request will redirect to remote server with localhost:8000 address.
unhandled
variableTo handle unhandled requests use unhandled
variable. It's behavior depends on Accept header. It can be used any accept header.
{
...
"unhandled": {
"html": { // <-- Accept header for html requests
...
},
"json": { // <-- Accept header for json requests
...
},
"xml": { // <-- Accept header for xml requests
...
},
"*": { // <-- Any accept header
...
}
}
...
}
Each accept header can contain its options.
"html": { // <-- Accept header for HTML requests (for example)
"status": 307, // <-- Response status code Temporary redirect, see 307 http status code
"headers": { // <-- Headers
"Location": "/"
}
},
"json": { // <-- Accept header for json requests
"status": 404, // <-- Response status code Not Found
"send": { // Response JSON object
"error": "JSON Not Found"
}
},
"xml": { // <-- Accept header for XML requests
"status": 404, // <-- Response status code Not Found
"send": "<error>Not Found</error>" // Response is text
},
"*": { // <-- Any accept header
"status": 404, // <-- Response status code Not Found
"file": "./www/not-found.txt" // Response read from file "./www/not-found.txt"
}
Server listening in 8080 port
{
"port": 8080,
"folders": "www",
"proxy": "localhost:4000"
}
/api
, otherwise request front-end by defaultServer listening in 8080 port
{
"port": 8080,
"folders": "www",
"proxy": {
"/api": "localhost:4000"
}
}
License Apache-2.0
Copyright 2020–2021 Oleksandr Lopatnov
FAQs
A back-end (Node.js) development tool to serve front-end projects with back-end reverse proxy for API. Configure a tool and serve your front-end projects
The npm package @lopatnov/express-reverse-proxy receives a total of 1 weekly downloads. As such, @lopatnov/express-reverse-proxy popularity was classified as not popular.
We found that @lopatnov/express-reverse-proxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.