• Stars
    star
    150
  • Rank 239,140 (Top 5 %)
  • Language
    Crystal
  • License
    Other
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rack proxy server for development (Crystal port)

Prax

Rack proxy server for development

This is an (almost) complete rewrite of Prax in Crystal, a Ruby-inspired language that compiles down to LLVM. This version should avoid problems with version managers, since Prax is now a binary application that don't rely on Ruby anymore (except for Rack and rackup).

Please refer to the wiki for more information:

Install

You can download a Debian / Ubuntu package for 64bits kernel on the releases page. For other systems, you'll have to follow the Manual Install Guide.

How it works

  1. resolves *.test and *.localhost domains to 127.0.0.1 and ::1 (localhost);
  2. redirects the :80 and :443 ports to :20559 and :20558;
  3. receives incoming HTTP requests and extracts the hostname (eg: myapp.test);
  4. serves static files directly if they exist;
  5. otherwise spawns a Rack applications (found at ~/.prax/myapp) if any;
  6. and proxies the request to the Rack aplication or a specified port for port forwarding.

Domain Resolver

systemd

If your distribution uses systemd-resolved, just use the .localhost TLD instead of .test —be prepared to fight against systemd if you want to use another TLD, or consider switching to a systemd free Linux.

.test TLD

Prax proposes 2 solutions to resolve .test and .localhost domains:

  • a dnsmasq configuration, either throught NetworkManager or by installing dnsmasq manually (eg. through your Linux distribution package);
  • an obsolete and deprecated NSSwitch extension, only compatible wih glibc and no longer compatible with Google Chrome/Chromium, and certainly more.

nip.io

Prax supports http://nip.io/ domains, so you can use myapp.129.168.0.1.nip.io for example. This is useful when using an external device like a smartphone, tablet or another computer to test your websites on.

Custom TLD

If .test or .localhost domains are not your cup of tea, no problem! Prax will route requests from any TLD to the applications in your ~/.prax directory, as long as the domain resolves to localhost.

For instance, if you wished to visit myapp.dev instead of myapp.test, you could create dnsmasq configuration to resolve .dev domains to localhost, too:

$ sudo tee /etc/dnsmasq.d/dev <<EOF
local=/dev/
address=/dev/127.0.0.1
address=/dev/::1
EOF
$ sudo service dnsmasq restart

Port Redirections

The port redirections are iptables rules, that are installed and removed using an initd script. The script redirects the port :80 and :443 on 127.0.0.1 and for each wlanX and ethX devices found on your machine, to allow incoming traffic, so you can use http://nip.io to test on external devices, as mentioned above.

You can install or remove the redirections with:

$ prax iptables [start|stop|restart|status]

Distribution packages should configure an init service to always install the iptables rules on machine startup or before starting prax (warning: this requires root privileges).

License

Prax is distributed under the CeCILL 2.1 license. Please see LICENSE for details.

HTML templates for rendering errors are from Pow!!, by Sam Stephenson and Basecamp, and are under the MIT license.

The NSSwitch extension originaly come from Hoof, by pyromaniac, and is under the MIT license.

Credits

Prax wouldn't exist without Pow!! by Sam Stephenson and Basecamp. Prax is nothing more but a reimplementation (in another language) with Linux compatibility in mind.

More Repositories

1

prax

Rack proxy server for development
Ruby
475
star
2

minitest.cr

Test Unit for the Crystal programming language
Crystal
144
star
3

frost

Web Framework for Crystal
Crystal
117
star
4

sdl.cr

SDL2 bindings for Crystal
Crystal
99
star
5

earl

Service Objects for Crystal (Agents, Artists, Supervisors, Pools, ...)
Crystal
94
star
6

http2

HTTP/2 Protocol Implementation for the Crystal Language
Crystal
93
star
7

gc

A garbage collector for Crystal
C
91
star
8

pool

Generic (connection) pools for Crystal
Crystal
76
star
9

artanis

Sinatra-like DSL for the Crystal language (abusing macros)
Crystal
56
star
10

selenium-webdriver-crystal

Selenium Webdriver client for the Crystal programming language
Crystal
56
star
11

posix

POSIX/C bindings generator for the Crystal programming language
Crystal
33
star
12

panzer

Multi-process, zero-downtime service monitor for Crystal
Crystal
29
star
13

android.cr

Create Android applications using Crystal and the NDK
Crystal
22
star
14

java.cr

Java Native Interface (JNI) bindings (and generator) for Crystal
Crystal
22
star
15

scrypt-crystal

Crystal bindings for Colin Percival's scrypt key derivation function
Crystal
21
star
16

muco

Multithreaded Coroutines library
C
20
star
17

crystal_library

Static/Shared libraries written in Crystal (Proof of Concept)
Crystal
20
star
18

crystal-cmark

Crystal wrapper for libcmark, the reference CommonMark C library
Crystal
18
star
19

syn

Synchronization primitives to build concurrent and parallel-safe data structures in Crystal
Crystal
17
star
20

nanolib.cr

Crystal
15
star
21

ruby-akismet

Ruby library for the Akismet anti-spam service.
Ruby
13
star
22

rome

Crystal
12
star
23

janus

Authentication engine for Ruby on Rails.
Ruby
12
star
24

shards-registry

Crystal
8
star
25

minitest-js

A JavaScript port of the minitest ruby gem
JavaScript
7
star
26

sql

SQL query builder for Crystal
Crystal
7
star
27

jsruby

Ruby Virtual Machine using node.js
JavaScript
6
star
28

microtest.cr

A test framework for raw Crystal (empty prelude)
Crystal
6
star
29

siphash.cr

SipHash family of pseudo random functions implemented in Crystal
Crystal
5
star
30

php5-redis

Yet another Redis client for PHP.
PHP
5
star
31

teascript

An attempt at creating a Ruby inspired language that compiles to JavaScript.
JavaScript
4
star
32

misago

Yet Another PHP 5 Framework
PHP
4
star
33

sinapse

Push service for Ruby using EventSource
Ruby
4
star
34

alpha

JavaScript
4
star
35

calliope

Blog engine for Ruby on Rails
Ruby
3
star
36

earl.rb

Service Objects for Ruby (Agents, Artists, Supervisors, Pools, ...)
Ruby
3
star
37

acts_as_enum

Treat an integer or string ActiveRecord column as a list of symbols.
Ruby
3
star
38

960-atatonic

CSS framework experiment based on 960 and Atatonic
3
star
39

pdoc

A minimalistic documentation tool for PHP.
PHP
3
star
40

ewkb

Crystal
2
star
41

pake

pake is meant to provide centralized CLI scripts to your PHP 5 projects
PHP
2
star
42

ng-rails-ujs

Angular directives for Rails UJS
JavaScript
2
star
43

markup

Ruby
2
star
44

redis_model

Ruby
2
star
45

zombie_admin

A brainless alternative to ActiveAdmin that speaks zombie fluently.
Ruby
2
star
46

mdown

Markdown editor with live preview (web app experiment)
Ruby
2
star
47

wyme

JavaScript
2
star
48

imhotep

Wiki engine for Ruby on Rails.
Ruby
2
star
49

acts_as_publish

Provides ActiveRecords with publishing capabilities
Ruby
2
star
50

alpha-control

JavaScript
2
star
51

ejs

ruby-like template engine for javascript
JavaScript
2
star
52

alpha-core

An obstrusive JavaScript library that aims at fixing, implementing and emulating standard JavaScript and DOM in broken and old browsers.
JavaScript
2
star
53

acts_as_sanitize

Sanitizes user data within ActiveRecord
Ruby
2
star
54

commentable

Ruby
2
star
55

sechat

Q&A engine for Ruby on Rails
Ruby
2
star
56

erb_assets

Render your Rails views into the Assets Pipeline
Ruby
1
star
57

rbs

Ruby inspired language that transcompiles to simple JavaScript
Ruby
1
star
58

dockerdev.cr

Crystal
1
star
59

swagger.cr

Crystal
1
star
60

brium-app

Crystal
1
star
61

calliper

Protractor for Ruby, or testing your Angular application with elegance
Ruby
1
star
62

execution_context

Crystal
1
star