Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redirectly

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redirectly

  • 0.4.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Redirectly - Redirect server with dynamic URL and hostname support

Gem Version Build Status Maintainability


Redirectly is a simple URL redirect server that uses a simple INI file for defining dynamic redirects.


Install

$ gem install redirectly

Docker Image

Redirectly is also available as a docker image:

# Pull the image
$ docker pull dannyben/redirectly

# Run the redirectly command line
$ docker run --rm -it dannyben/redirectly --help

# Start the server with your local configuration file
$ docker run --rm -it \
    -p 3000:3000 \
    -v $PWD/redirects.ini:/app/redirects.ini \
    dannyben/redirectly 

Using with docker-compose

# docker-compose.yml
services:
  redirectly:
    image: dannyben/redirectly
    ports:
      - 3000:3000
    volumes:
      - ./redirects.ini:/app/redirects.ini

Using as an alias

$ alias redirectly='docker run --rm -it -p 3000:3000 -v $PWD/redirects.ini:/app/redirects.ini dannyben/redirectly'

Quick Start

# In an empty directory, create a sample configuration file
$ redirectly --init

# Start the server
$ redirectly

# In another terminal, access the server using one of the configured rules
$ curl -v something.localhost:3000

You should receive a redirect header:

# ...
< HTTP/1.1 302 Found
< Location: http://it-works.com/something
# ...

Usage

Redirectly requires a simple INI file with redirect configuration details.

You can create a sample configuration file by running:

$ redirectly --init

This will create a sample redirects.ini file:

example.com = https://other-site.com/
*.mygoogle.com/:anything = https://google.com/?q=%{anything}
example.org/* = https://other-site.com/
*.old-site.com = !https://permanent.redirect.com
:sub.app.localhost/* = http://it-works.com/%{sub}
proxy.localhost/*rest = @https://proxy.target.com/base/*rest
internal.localhost/reload = :reload
(*)old-domain.com/*rest = http://new-domain.com/%{rest}

For additional server options, see:

$ redirectly --help

The configuration file is built of pattern = target pairs, where:

  • pattern - is any URL pattern that is supported by Mustermann.
  • target - is the target URL to redirect to.

Special INI Notation

Redirect type

If the target starts with !, a permanent redirect (301) will be performed.
If it does not, a temporary redirect (302) will be performed by default:

test.localhost/temporary = http://example.com
test.localhost/permanent = !http://example.com
Proxying

If the target starts with @, the content will be proxied instead of being redirected:

test.localhost = @http://example.com
Named arguments

Patterns that include strings starting with a colon : will expose those strings as Ruby substitution variables in the target:

test.localhost/:anything = http://example.com/path/%{anything}
Splats

You can use a splat * or a named splat *name in the pattern.
Named splats will also be exposed as Ruby substitution variables in the target:

(*)test.localhost/*rest = http://example.com/%{rest}

Contributing / Support

If you experience any issue, have a question or a suggestion, or if you wish to contribute, feel free to open an issue.


FAQs

Package last updated on 14 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc