+++ /dev/null
-serve:
- lighttpd -D -f lighttpd.conf
-
-front:
- lighttpd -D -f example_frontend.lighttpd.conf
-
-clean:
- -${RM} -frfr out/
- -${RM} errors.log
-# Upchud
-> File upload service; without stage 4 retardation.
+Sane deployment of [anon's upchud](https://git.xolatile.top/anon/upchud) for nginx.
-### Shilling points 🚀:
-* Minimal dependencies
-* CLI friendly
-* Web friendly
-* Optional random upload name mangling
-* Easy to configure
-* Small codebase
-* Traubisoda
+Things that need to change for deployment are the up.chud.cyou nginx file and crontab.
-### Depedencies
-* Lighttpd
-* Tcl (base installation)
-
-### Files
-| File | Description |
-| :------------ | :---------- |
-| lighttpd.conf | Master lighttpd configuration. Tip: set max upload size here. |
-| upchud.tcl | Master CGI Tcl script. Tip: simply forked by lighttpd; set finer configurations here. |
-| Makefile | Short-hands for common operations. |
-| test/* | Scripts and files used during development. |
-| example\_frontend.html | Simple web front-end for the service. |
-| example\_frontend.lighttpd.conf | Serves the example front-end. Tip: you could merge this with the master configuration if you wanted one service. |
-
-### Usage
-Lets get hello-world out-of the way:
-```sh
-$ make serve &
-[1] 15225
-lighttpd -D -f lighttpd.conf
-$ curl http://localhost:8080 --upload-file test/test.txt
-http://localhost:8080/out//n6cru4.txt
-$ curl http://localhost:8080/out//n6cru4.txt
-Hello World
-```
-
-Alternatively I could run.
-```sh
-$ make serve &
-[1] 23895
-lighttpd -D -f lighttpd.conf
-$ make front &
-[2] 24105
-lighttpd -D -f example_frontend.lighttpd.conf
+The nginx & crontab files expect:
+```tcl
+set outdir "out/"
+set keep_outdir 0
```
-And I could use the web page (localhost:8081 by default) to perform the same task.
-
-The example frontend is perfectly functional, but is meant to be modified.
-Alternatively, you could copy and embed it anywhere else on your site at large.
-
-To learn more about configuration, read the top of `upchud.tcl` and checkout `lighttpd.conf`
-### Why?
-Because every implementation of this extremely simple thing is flawed.
-Common faults I witnessed are:
-* CLI is second class with sloppy wrapper scripts and or HTML responses
-* No web support, preventing phoneposting
-* Horrifically convoluted configuration due to poor isolation of responsibilities
-* 6 gorillion dependencies
+keep_outdir is a patched in feature.
+++ /dev/null
-* include some tmp file cleaner scripts or atleast leave recommendations
-* by spoofing the request, it might be currently possible to upload files
-to a parent dictionary; this should be tested and fixed, but should be fine
-as long as the person running the service doesnt run it as root
--- /dev/null
+@monthly find /var/www/up.chud.cyou/out/ -type f -mtime +28 -exec rm {} \;
+++ /dev/null
-<div style="width: 400px;">
- <form action="http://localhost:8080" method="post" enctype="multipart/form-data">
- <fieldset>
- <legend>Upload a file</legend>
- <label>
- Select file:
- <input type="file" name="file" required>
- </label>
- <button type="submit">Upload</button>
- </fieldset>
- </form>
-</div>
+++ /dev/null
-# @BAKE lighttpd -D -f $@
-server.document-root = var.CWD
-server.port = "8081"
-
-server.modules += ( "mod_rewrite" )
-url.rewrite-once = ( ".*" => "/example_frontend.html" )
--- /dev/null
+<!DOCTYPE html>
+<html prefix="og: http://ogp.me/ns#" lang="en">
+ <head>
+ <link rel="canonical">
+ <link rel="icon" type="image/png" sizes="32x32" href="/chud/img/favicon.png">
+ <link rel="stylesheet" type="text/css" href="https://xolatile.top/style.css">
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=0.5">
+ <title id="title">up.chud.cyou</title>
+ </head>
+ <body>
+ <div style="width: 50em;">
+ <form action="https://up.chud.cyou/upchud.tcl" method="post" enctype="multipart/form-data">
+ <fieldset>
+ <legend>Upload a file</legend>
+ <label>
+ Select file:
+ <input type="file" name="file" required>
+ </label>
+ <button type="submit">Upload</button>
+ </fieldset>
+ </form>
+ <p>You may upload files using the above form or the following command:</p>
+ <pre>
+ curl --upload-file 'file' https://up.chud.cyou/
+ </pre>
+ <p>
+ Files are wiped monthly and may not be larger than 100 mebibytes.
+ </p>
+ <p>
+ Upchud is a FOSS file uploader service, originally developed for
+ <a href="https://up.chud.cyou/">up.chud.cyou</a>
+ </p>
+ <p>
+ Original source:
+ <a href="https://git.xolatile.top/anon/upchud">git.xolatile.top/anon/upchud</a>
+ <br />
+ This deployment's source:
+ <a href="https://git.xolatile.top/emil/up.chud.cyou">git.xolatile.top/emil/up.chud.cyou</a>
+ </p>
+ </div>
+ </body>
+</html>
+++ /dev/null
-# @BAKE lighttpd -D -f $@
-server.document-root = var.CWD
-server.port = "8080"
-
-server.modules += ( "mod_rewrite" )
-url.rewrite-once = (
- "^/out/.*" => "$0",
- ".*" => "/upchud.tcl"
-)
-
-# This limits the maximum upload size (in kbytes).
-server.max-request-size = 204800 # 200 MiB
-
-# This makes sure people cant inject Tcl scripts
-server.modules += ( "mod_cgi" )
-$HTTP["url"] == "/upchud.tcl" {
- cgi.assign = ( ".tcl" => "" )
-}
-
-
-debug.log-request-header = 1
-debug.log-file-not-found = 1
-debug.log-condition-handling = 1
-debug.log-request-handling = 1
-debug.log-state-handling = 1
-debug.log-response-header = 1
-
-server.errorlog = "errors.log"
+++ /dev/null
-#!/usr/bin/tclsh
-
-set f [open "evil.txt" "w"]
-close $f
-
-puts stderr "evil.txt created"
+++ /dev/null
-Hello World
+++ /dev/null
-#!/bin/sh
-curl --upload-file example.png http://localhost:8080/
--- /dev/null
+map $http_user_agent $cli {
+ default 0;
+ ~*wget 1;
+ ~*curl 1;
+}
+
+server {
+ server_name up.chud.cyou;
+ root /var/www/up.chud.cyou;
+
+ listen 80;
+ listen [::]:80;
+ listen 443 ssl http2;
+ listen [::]:443 ssl http2;
+
+ ssl_certificate ...;
+ ssl_certificate_key ...;
+
+ error_page 404 https://up.chud.cyou/chud/404;
+
+ location ~ /\.git {
+ deny all;
+ }
+
+ client_max_body_size 100m;
+
+ location ^~ /out/ {
+ autoindex on;
+ }
+
+ location = /upchud.tcl {
+ # include authorized;
+ # deny all;
+ include fastcgi_params;
+ fastcgi_pass unix:/var/run/fcgiwrap.socket;
+ fastcgi_param SCRIPT_FILENAME /var/www/up.chud.cyou/upchud.tcl;
+ }
+
+ if ($cli) {
+ rewrite ^/.*$ /upchud.tcl last;
+ }
+ rewrite ^/$ /index.html last;
+ rewrite ^/upchud.tcl$ /upchud.tcl last;
+ rewrite ^/(.+)$ /out/$1;
+}
# ---
# Directory to place the files to.
set outdir "out/"
+set keep_outdir 0
# The lenght of the random name every file is assigned.
# Setting it to 0 disables random name mangling.
set mangle_lenght 6
set output_name [get_out_name $original_name]
eval $write_file $output_name
-send_success $output_name
-
+if { $keep_outdir } {
+ send_success $output_name
+} else {
+ send_success [file tail $output_name]
+}
## Notes
# This is a very useful debug snippet:
#