A simple, configurable proxy server that will hit a chain of sources before failing.
A common problem when working in a dev environment with production data is that some assets will need to point to local files and others will need to point to production servers (depending on the environment they were created in). Managing this within the application can be infeasible – that's where peroxide comes in.
Attempt to serve files locally, then fall back to staging or production sources.
$ npm install -g peroxide$ peroxide --port=8000 --config=./sources.json
With the above configuration, you can request files like:
The format follows (
path is relative to each source):
- "http" – Attempts to fetch the asset over HTTP (options: path, timeout).
- "filesystem" – Reads from the filesystem (options: path).
- "pipe" – Pipes the readable stream straight to the response.
- "buffer" – Buffers the resource before sending it to the browser.
Serving content over HTTPS is supported by passing additional flags on the command line.
$ peroxide \--port=8000 --config=./sources.json --ssl \--key /etc/apache2/ssl/server.key \--cert /etc/apache2/ssl/server.crt
Example init.d scripts are provided in the "init.d" directory. Copy "./init.d/peroxide" to
/etc/init.d/peroxide and "./init.d/default" to
Configure the default values (i.e. port, config file location, ssl options) in
Peroxide adds a
X-Content-Source response header that makes it possible to tell where the file came from:
If no source is able to serve the file, a
404 Not Found status will be provided. The body will be a
text/plain description containing all the paths that were attempted.
Copyright © 2013 – Creative Market
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.