-
Notifications
You must be signed in to change notification settings - Fork 0
self hosting
This page describes how to install and configure your own Npm2Mvn proxy. The server is very lightweight, simple to configure, and may be used in a variety of situations. You may run your own local proxy for you own projects. You could run one on your company network, or even on the public internet.
Get an installer for your operating system from the Releases page.
Note, the releases page will only contain major versions. You should also use the built-in updater to get access to point releases or developer builds. See Updating below.
For all operating systems, you simply run the installer as you would any other application.
- On Windows, just double click the downloaded installer and follow the prompts.
- On Linux, after downloading make the installer executable before executing. Then either run from your file manager or use a terminal to executed the installer directly.
- On Mac OS, just double click the package and follow the prompts.
The installer can also be run from the command line, e.g. on a remote server over SSH, and supports a number of options.
-q Run the installer in unattended node.
-c Run the installer in console mode.
When installation is complete, a new system service will be running listening on port 9080. To test the server, point you browser to http://localhost:9080. The service will also be configured to start on boot.
Configuration is achieved by editing npm2mvn.vmoptions.
# Lines starting with a '#' are commented out.
# Port for Http requests. Defaults to 9080 if no https portt
#-DhttpPort=80
# Port for Http requests.
#-DhttpsPort=443
# Address to listen on, defaults to localhost.
-DbindAddress=0.0.0.0
# Where web resources (the mini home page) are found
-DwebResources=web/live
# Where access logs will be stores
-DaccessLogs=logs
# Where SSL keystore is located
-DkeystoreFile=ssl/keystore
# The password for the keystore
#-DkeystorePassword=changeit
# The password for the key
#-DkeyPassword=changeit
# The type of key store
#-DkeystoreType=JKS
# It is recommended the options below are not changed unless you have special requirements
# The cache directory. Defaults to $HOME/.m2/npm2mvn/cache
#-DcacheDir=/some/path
# The path prefix for all requests
#-Dpath=/some/path
# The group id to use for all transformed packages
#-DgroupId=npmThese should all be self explanatory. If you make any changes the service must be restarted.
Note, there is also a npm2mvnc.vmoptions file, this used for the console variant of the server used for troubleshooting.
Npm2Mvn can also serve any static resources such as CSS, Javascript or images, as well as a single templated index.html page. The HTML template uses our own TinyTemplate, and supports the variable replacements detailed below.
To use this, drop your files in the webResources directory, which by default is web/live. You can also find the default sample site in web/sample which may be copied to web/live to get you started.
| Variable | Description |
|---|---|
| serverUrl | The address of the page being displayed in the browser, from the client's perspective. |
| groupId | The configured groupId, will normally be npm |
To enable HTTPS support, you must first enable the httpsPort option. Edit npm2mvn.vmoptions and un-comment the option, altering the port from the default 443 to suit your needs.
Next to you need to import your certificate into the keystore using the Java's keytool command. You can find the keytool command installed along with Npm2Mvn in the jre/bin directory.
By default, Npm2Mvn expects the keystoreFile to exist at $HOME/.keystore, and the password of the store and key to be changeit. If you need to change any of these, alter npm2mvn.vmoption to suite.
Once configured, and with the certificate imported to the keystore, you can restart the service and HTTPS should now be working on your chosen port.
The server should look after itself for the most part, but there are some things you should be aware of.
To reduce bandwidth costs and aid performance, transformed Npm packages will be cached, along with other data useful for support a Maven repository layer such as hashes and pom files.
There is currently no automatic cleaning of this cache, so in the meantime you should monitor the cacheDir location for disk usage. By default, this will be $HOME/.m2/npm2mvn/cache.
TODO
You may wish to the run service in foreground mode for troubleshooting purposes. Make sure the service is shutdown, and then simply run npm2mvnc (or npm2mvnc.exe on Windows).
Instead of logging to the logs directory, and output will appear on the console.
TODO