
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
fastify-vhost
Advanced tools
Proxy subdomain http requests to another server.
This fastify
plugin forwards all the requests
received with a given subdomain to an upstream.
fastify-vhost
is powered by the popular Nodejitsu http-proxy
.
This plugin can be used if you want to point multiple (sub)domains to the same IP address, while running different servers on the same machine.
Prior to fastify-vhost@1.1.3
we only supported fastify@1.x.x
. We are proud to announce that fastify-vhost
now supports both v1, v2 and v3!
npm i fastify-vhost fastify
const Fastify = require('fastify')
const server = Fastify()
server.register(require('fastify-vhost'), {
upstream: 'http://localhost:3000',
host: 'test.example.com'
})
server.listen(80)
This will proxy any request to the test
subdomain to the server running at http://localhost:3000
. For instance http://test.example.com/users
will be proxied to http://localhost:3000/users
.
If you want to have different vhosts for different subdomains you can register multiple instances of the plugin as shown in the following snippet:
const Fastify = require('fastify')
const server = Fastify()
const vhost = require('fastify-vhost')
server.register(vhost, {
upstream: 'http://localhost:3000',
host: 'test.example.com'
})
server.register(vhost, {
upstream: 'http://localhost:3001',
host: 'other.example.com'
})
server.listen(80)
You can also specify multiple aliases for each vhost with the hosts
option:
const Fastify = require('fastify')
const server = Fastify()
const vhost = require('fastify-vhost')
server.register(vhost, {
upstream: 'http://localhost:3000',
hosts: ['test.example.com', 'test2.example.com']
})
server.register(vhost, {
upstream: 'http://localhost:3001',
host: 'other.example.com'
})
server.listen(80)
The above example would behave the same as the following:
const Fastify = require('fastify')
const server = Fastify()
const vhost = require('fastify-vhost')
server.register(vhost, {
upstream: 'http://localhost:3000',
host: 'test.example.com'
})
server.register(vhost, {
upstream: 'http://localhost:3000',
host: 'test2.example.com'
})
server.register(vhost, {
upstream: 'http://localhost:3001',
host: 'other.example.com'
})
server.listen(80)
But in a much neater way.
Notice that it is CRITICAL to provide the full host
(subdomain + domain) so that it properly routes the requests across different upstreams.
For other examples, see example.js
.
This fastify
plugin supports the following options.
Note that this plugin is fully encapsulated and payloads will be streamed directly to the destination.
An URL (including protocol) that the requests will be forwarded to (eg. http://localhost:3000).
The host to mount this plugin on. All the requests to the current server where the host
header matches this string will be proxied to the provided upstream.
Equivalent to the host
option, but an array of strings. All the requests to the current server where the host
header matches any of the strings will be proxied to the provided upstream.
Default: false
. When strict mode is enabled, the host header has to be an exact match. When disabled, 'EXAMPLE.COM', 'example.com' and 'example.com:3000' will match 'example.com'.
Default: 30000
. Timeout in milliseconds for the proxy to return a 504 Gateway Timeout
.
None yet. But you're welcome to open a PR.
MIT
FAQs
Proxy subdomain http requests to another server
The npm package fastify-vhost receives a total of 10 weekly downloads. As such, fastify-vhost popularity was classified as not popular.
We found that fastify-vhost demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.