Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions order/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ A small Python service behind nginx on a Debian host.
Checkout (an open one is reused) that collects card, email, phone and the shipping address in the
quote's country, and shows the price-may-change terms beside Pay. There is no quote page: the quote is
only shown in Backplane. Stripe comes back to `/q/{id}/done` or `/q/{id}/cancelled`, one line each.
- `/admin`: paid orders, to place by hand. Takes `?k=$FAB_ADMIN_TOKEN` once, which then
becomes a cookie.
- `/admin`: paid orders, to place by hand. nginx asks for a password first (user `admin`, a bcrypt
line in `/etc/nginx/fab-admin.htpasswd`, made with `mkpasswd -m bcrypt`) and then hands the app its
token from `/etc/fab/nginx-admin.conf`; without that file the page takes `?k=$FAB_ADMIN_TOKEN` once,
which then becomes a cookie.

The person sees three lines and a total, four for the US:
- manufacturing;
Expand Down
17 changes: 17 additions & 0 deletions order/deploy/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
limit_req_zone $binary_remote_addr zone=fab_api:10m rate=5r/s;
limit_req_zone $binary_remote_addr zone=fab_up:10m rate=6r/m;
limit_conn_zone $binary_remote_addr zone=fab_conn:10m;
limit_req_zone $binary_remote_addr zone=fab_admin:10m rate=30r/m;

# no query strings in the log: they can carry a quote's token
log_format fab '$remote_addr [$time_local] "$request_method $uri" $status $body_bytes_sent $request_time';
Expand Down Expand Up @@ -45,6 +46,22 @@ server {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
}
# The order list: a password (user admin; bcrypt hash in /etc/nginx/fab-admin.htpasswd, readable by
# www-data) and then the app's own admin token, which nginx adds from /etc/fab/nginx-admin*.conf
# (root only; one line: proxy_set_header Cookie "fab_admin=<FAB_ADMIN_TOKEN>";). With no password
# file every /admin request fails; with no token file the page asks for ?k= as before.
location ^~ /admin {
limit_req zone=fab_admin burst=20 nodelay;
auth_basic "Backplane orders";
auth_basic_user_file /etc/nginx/fab-admin.htpasswd;
client_max_body_size 256k;
proxy_pass http://127.0.0.1:8090;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
include /etc/fab/nginx-admin*.conf;
}
location / {
limit_req zone=fab_api burst=40 nodelay;
client_max_body_size 256k;
Expand Down
Loading