Setup npm Proxy with DevGuard Dependency Proxy
Setup
- Registry URL:
http://localhost:8080/api/v1/dependency-proxy/npm - Configuration: Set in
.npmrcfile
Using a configuration file
Create or edit .npmrc in your project directory:
registry=http://localhost:8080/api/v1/dependency-proxy/npm
strict-ssl=false # only for local testing; use true in productionThen install packages normally:
npm install lodashTesting
DevGuard includes test packages for verifying the proxy functionality:
fake-malicious-npm-package
These test packages are safe to use and will always be blocked by the proxy.
Example Test
Create a test project with a malicious package:
package.json (npm):
{
"dependencies": {
"lodash": "^4.17.21",
"fake-malicious-npm-package": "1.0.0"
}
}Run npm install:
- ✅
lodashwill install successfully - ❌
fake-malicious-npm-packagewill be blocked
API Reference
Proxy Endpoints
GET /api/v1/dependency-proxy/npm/*
Response Headers
X-Cache: HIT|MISS- Indicates if the response was served from cacheX-Proxy-Type: npm- Identifies the proxy typeX-Malicious-Package: blocked- Present when a package is blocked
Status Codes
200 OK- Package successfully proxied403 Forbidden- Malicious package blocked503 Service Unavailable- Database not yet loaded502 Bad Gateway- Upstream registry error