Git Product home page Git Product logo

boxcars-archived's Introduction

No more maintained

It turns out, this is not a good idea and I don't maintain this project anymore.

Boxcars

Easy-to-configure Static Web/Reverse Proxy Server in Go.

Install

$ go get github.com/azer/boxcars/boxcars

Works with Go v1.1+

Usage

Create a configuration file (it'll be auto-loading changes once you start) like the below example;

{
  "foo.com": "/home/you/sites/foo.com",
  "*.bar.net": "localhost:8080",
  "qux.org": {
    "/static": "/home/you/qux.org/static",
    "/favicon.ico": "/home/you/qux.org/static/favicon.ico",
    "/": "localhost:3000"
  }
}

And start the server:

$ boxcars config.json

To specify the port:

$ boxcars -port=8001 config.json

Always enable secure mode when running as sudo:

$ sudo boxcars -port=80 -secure config.json

You can change the configuration anytime during boxcars running. It'll be watching your file and reloading it only if it parses with no error.

Configuration Examples

I use below configuration for a static single-page app that connects to an HTTP API:

{
  "singlepage.com": {
    "/api": "localhost:1337",
    "*": "sites/singlepage.com"
  }
}

To catch any domain:

{
  "foo.com": "localhost:1234",
  "*": "/home/you/404.html"
}

To set a custom 404 page for a static server:

{
  "foo.com": {
    "/": "/home/you/sites/foo.com",
    "*": "/home/you/404.html"
  }
}

Security

Once you enable -secure, boxcars switches from root user to a basic user after starting the server on specified port.

$ sudo boxcars -port=80 -secure example.json

UID and GID is set to 1000 by default. Use -uid and -gid parameters to specify your own in case you need.

Logging

Boxcars uses debug for logging. To enable logging for specific modules:

$ DEBUG=server,sites boxcars config.json

To see how boxcars setup the HTTP handlers for your configuration;

$ DEBUG=handlers-of,sites boxcars config.json

To enable very verbose mode (not recommended):

$ DEBUG=* boxcars config.json

To silentize:

$ DEBUG=. boxcars config.json

It'll be outputting to stderr.

Benchmarks

Troubleshooting

The "Too Many Open Files" Error

Boxcars creates a lot of files on /proc/$pid/fd. In case you see boxcars crashing, you can see how many files are open by;

$ sudo ls -l /proc/`pgrep boxcars`/fd | wc -l

To find out your personal limit:

$ ulimit -n

To change it:

$ ulimit -n 64000

You can change soft - hard limits by editing /etc/security/limits.conf.

TODO

  • Add -daemon option.

boxcars-archived's People

Contributors

crosbymichael avatar danclien avatar justinazoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

boxcars-archived's Issues

README should explain the problem it solves.

Please take this entire description as well-intended constructive criticism. It is not meant to be offensive, but to help the project. I'm not singling out boxcars, I feel this way about a LOT of projects.

Reading the README, the only explanation given is

Easy-to-configure Static Web/Reverse Proxy Server in Go.

What does that mean? Why would I want to use it? What problem does it solve? This description is most useful to the developer who wrote it, not to the majority of potential users.

I'm a fairly experienced developer, familiar with what reverse proxies do, and even for me, there's nothing there to tell me why I should consider this instead of nginx. Yes, hidden down under benchmarks is a speed comparison with nginx, but having "it's similar in functionality to nginx, but faster" (or whatever is the most important distinction) would be cool up top.

If I were unfamiliar with nginx (or didn't know what a reverse-proxy did in general), and I was maybe a Python or Ruby developer who could take advantage of such a project, there's nothing in the description to tell me I can use this to serve my application. If I did a Google or Github search, I'd almost certainly never encounter this project with the keywords I'd use.

Anyone who's ever been trained in sales knows you always need to sell the benefits, not the features. Most people won't get excited about the specs of a gigabit fiber connection, but tell them they can do in two seconds what currently takes an hour and they'll get out their wallet.

Support HTTP/2.0

Unfortunately the projects doesn't seem to be maintained anymore, which is sad, because it looks really promising. But anyway, right after #8 I'd like to have HTTP 2 support.

cannot run secure on port 80

I'm trying to use boxcars as static file server + reverse proxy on port 80, while dropping privileges, but I get an error:

  server Fatal: listen tcp :80: bind: permission denied +1

I think the solution to this is that boxcars needs to open a listen port first, then drop uid/gid privileges, then start the HTTP server (i.e. not calling ListenAndServe, but calling Serve).

Drop privileges

A guy on hackernews had the time to post code but didn't want to send a pull request because github is hard or something. It might be worth considering doing something similar.

Error installing

$ /usr/bin/go get github.com/azer/boxcars/boxcars
# github.com/azer/go-style
/usr/lib/go/src/pkg/github.com/azer/go-style/style.go:10: regexp.MustCompile("[^\\w]+").Split undefined (type *regexp.Regexp has no field or method Split)
$ /usr/bin/go version
go version go1.0.2

Support binding to multiple ports

You can only bind to one port. It would be a great feature to be able to bind to multiple ports, and have vhosts support multiple ports as well.

unable to work if backend with own self-signed cetification ?

#I have 3 sites want to work behind the boxcars
but only one works.
here is the config

   "ost.abc.com": "http://192.168.11.221",
   "mail.abc.com": "https://192.168.11.173/mail",                                                                                                       
   "neodev.abc.com:": "https://192.168.11.21"
 }  

ost.abc.com is a simple LEMP website , and it works behind the reverse proxy
mail.abc.com is a webmail with self-signed certification

  handlers-of Setting up the HTTP handler that will serve https://192.168.11.173/mail +3
  servers Returning a reverse proxy server for https://192.168.11.173/mail. +3
  on-request Routing mail.abc.com/ +15045
  match Iterating patterns: / +15045
  match Matched mail.abc.com/ with the handler attached to /. +15045
  match Returning matching site for mail.abc.com/. +15045
2018/05/28 02:21:24 http: proxy error: x509: cannot validate certificate for 192.168.11.173 because it doesn't contain any IP SANs

any suggestions to fix the problem ?

and neodev.abc.com is a nginx-django website with a self-signed cetification
the error log below

  on-request Routing neodev.abc.com/ +145590
  match Nothing attached to neodev.abc.com or *.abc.com +145590
  match Unable to find any matching site for neodev.abc.com +145590

any suggestions ?

Support Redirects

It would be cool to be able to specify something like

{
    ...
    "something.com": [ "redir", "http://internal.something.com" ],
    ...
 }

Boxcars is not thread-safe

The package github.com/azer/debug is not thread-safe. Therefore whenever you call debug() you'll get a race condition. You can test it yourself with go run -race boxcars.go config.json:

screenshot on 2013-08-16 at 01 33 51

On this line: https://github.com/azer/debug/blob/master/caption.go#L24 , colorOf is not locked and multiple goroutines are assigning on the same time to the map. And maps in Go are not thread-safe. I've opened a Pull-request for caption that solves this.

Support SSL

It's be nice to have the ability to load a SSL certificate and serve an encrypted connection over HTTPS.

how to define index file lists

like below:

{
  "indexFiles": "index.html,index.htm,index.php"
}

also, if all index files fail, should show a 404 page?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.