Skip to content
Question boxy with Rust
Rust JavaScript CSS HTML Dockerfile
Branch: master
Clone or download
BlueCocoa updated screenshot
Signed-off-by: Cocoa <0xbbc@0xbbc.com>
Latest commit cb6595b Dec 30, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
conf added `web_root` to configuration Dec 30, 2019
src get a specific question Dec 30, 2019
web.example added sign in/sign out button Dec 30, 2019
.dockerignore added .dockerignore Dec 29, 2019
.gitignore ignore web/* Dec 30, 2019
Cargo.toml initial version of boxy server side Dec 29, 2019
Dockerfile relocated configuration file Dec 29, 2019
LICENSE updated README.md and added LICENSE Dec 30, 2019
README.md
docker-compose.yml added sign in/sign out button Dec 30, 2019
screenshot.png updated screenshot Dec 30, 2019

README.md

boxy

Question box with Rust

My question box ask.cocoa.me.uk

You may refer to my blog post for more detials~

screenshot

Usage

With docker-compose

With docker-compose, it should be super easy.

cp conf/config.example.json conf/boxy.json
cp -rf web.exmaple web
docker-compose up -d

Port 5534 is exposed, and you can use nginx or Apache as proxy. And I opt for nginx, so code below is my configuration

server {
  if ($host = ask.cocoa.me.uk) {
    return 301 https://$host$request_uri;
  } # managed by Certbot

  listen 80;
  listen [::]:80;
  server_name ask.cocoa.me.uk;
  return 404; # managed by Certbot
}

server {
  listen 443 ssl http2; # managed by Certbot
  listen [::]:443 ssl http2; # managed by Certbot
  
  server_name ask.cocoa.me.uk; # managed by Certbot

  ssl_certificate /etc/letsencrypt/live/cocoa.me.uk-0001/fullchain.pem; # managed by Certbot
  ssl_certificate_key /etc/letsencrypt/live/cocoa.me.uk-0001/privkey.pem; # managed by Certbot
  include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  
  ssl_session_cache shared:TLS:2m;
  ssl_buffer_size 4k;

  add_header Strict-Transport-Security "max-age=31536000";

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;

    proxy_pass http://localhost:5534;
    proxy_redirect off;
  }
}

With my own MongoDB

And it's not hard if you prefer to use your own MongoDB server

First copy the example configuration file to conf/boxy.json

cp conf/config.example.json conf/boxy.json
cp -rf web.exmaple web

Then edit conf/boxy.json with your favorite editor. You need to specify mongodb_url, mongodb_db, mongodb_username and mongodb_password

docker build -t boxy .
docker run -d \
  --restart=always \
  -p 5534:5534 \
  -v "`pwd`/conf:/etc/boxy" \
  -v "`pwd`/web:/web" \
  boxy

Customize Webpage

If you want to customize the webpage, then you may edit your web page in some directory, e.g, /var/www/boxy.

And now, if you are using Docker, then just map /var/www/boxy/ to /web

If you are going to run this as a standalone application, you need to set web_root in boxy.json to /var/www/boxy/.

API

You may refer to my blog post for API details. I'm currently too sleepy to copy those here.

Acknowledgements

This project uses many other projects on GitHub or on the internet, without them this project can be done, but it will take literally forever XD. Massive thanks to them.

Web

Rust

There are some crates that directly used in this project, but actucally there are plenty more crates behind these.

bson = "0.14"
crossbeam-channel = "0"
ctrlc = "3"
futures = "0.1"
hmac = "0.7"
hyper = "0.12"
lazy_static = "1.4"
mongodb = "0.9"
regex = "1"
serde_json = "1.0"
serde = "1"
sha2 = "0.8"
You can’t perform that action at this time.