summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md171
1 files changed, 171 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..67689ad
--- /dev/null
+++ b/README.md
@@ -0,0 +1,171 @@
1# ngus
2
3*ngus* is a minimalist HTTP server written in pure Python and intended for
4receiving file uploads
5
6
7## Motivation
8
9The reason for writing this small package was the need to transfer files from
10a Windows desktop machine running on a highly restricted VPN to my GNU and UNIX
11systems.
12
13Since the HTTP traffic (out) was not restricted, I started looking for a small
14, yet flexible HTTP server that could satisfy the following criteria:
15
16- can be configured with the help of a few CLI parameters
17
18- can be started and stopped quickly by an unprivileged user
19
20- be able to receive uploads to a specific directory
21
22- be portable and require a minimal amount of dependencies
23
24- be part of the C/C++ or Python ecosystems
25
26To my amazement I wasn't able to find any free software matching that criteria.
27
28
29## Overview
30
31The main purpose of *ngus* is to accept file uploads as POST requests from an
32HTTP client.
33
34Currently *ngus* does not provide encryption (HTTPS) support. Many different
35tools can be employed to serve as an HTTPS proxy.
36
37See the examples bellow for more details!
38
39
40## Installation
41
42### pip (pypi)
43
44 ```bash
45 pip install ngus
46 ```
47
48
49### Gentoo
50
51 ```bash
52 layman -a sgs
53 emerge www-servers/ngus
54 ```
55
56
57## Examples
58
59When installing *ngus* as described above, a dedicated *ngus* script
60(entry point) will be installed in addition to the *ngus* Python module.
61
62Running:
63
64 ```bash
65 ngus -h
66 ```
67
68will be for all practical purposes the same as running:
69
70 ```bash
71 python -m ngus -h
72 ```
73
74The latter format will be used for the rest of this section.
75
76
77 ```bash
78 python -m ngus -H 0.0.0.0 -p 8080
79 ```
80
81will start the server, binding port 8080 on all available interfaces and
82storing the received uploads in the current working directory (CWD), while
83
84 ```bash
85 python -m ngus -H 0.0.0.0 -p 8080 -u /home/s/uploads
86 ```
87
88will store them in `/home/s/uploads`
89
90**Note:** This will allow *ngus* to replace any existing file in this directory.
91
92Once the server is running a client will be able to send a POST form with a
93file data. One can always access the URL (send a GET request) with a regular
94browser and use the provided form or simply use a client like *curl* for
95posting (sending a POST request) a form.
96
97 ```bash
98 curl -F "ufile=@myfile.zip" http://158.39.125.240:8080
99 ```
100
101The default form input field name is *ufile*. That can be changed by using the
102*--input-name* parameter. Basic auth support can be added with the
103*--basic-auth* parameter.
104
105 ```bash
106 python -m ngus -H 0.0.0.0 -p 8080 -i uploadfile -b "uname:foo" -u /home/s/uploads
107 curl --basic -u uname -F "uploadfile=@myfile.zip" http://158.39.125.240:8080
108 ```
109
110
111### Using *nginx* as a proxy
112
113*ngus* will usually not be run on ports 80 (HTTP) and 443 (HTTPS) since binding
114them requires administrator (root) privileges.
115
116Running *ngus* on a unprivileged port (> 1024) may not solve the problem
117described above. Namely a potential client may not be able to communicate to
118ports other than 80 and 443 because of imposed firewall / VPN restrictions.
119
120Another potential challenge arises when *ngus* runs on a host that is not
121publicly accessible.
122
123*nginx* can be used to proxy the traffic toward *ngus* instance running as
124described in the examples above.
125
126 ```nginx
127 server {
128
129 listen 443 ssl;
130 listen 80;
131 server_name uploads.myhostname.net;
132
133 access_log /var/log/nginx/uploads.myhostname.net.access.log;
134 error_log /var/log/nginx/uploads.myhostname.net.error.log error;
135
136 ssl_certificate uploads.myhostname.net.cert.pem;
137 ssl_certificate_key uploads.myhostname.net.key.pem;
138
139 location / {
140 # point at the ngus instance running on a private network address
141 proxy_pass http://192.168.1.240:8080/;
142 }
143
144 }
145 ```
146
147... and then upload a file with:
148
149 ```bash
150 curl -F "ufile=@myfile.zip" https://uploads.myhostname.net
151 ```
152
153
154## Support and contributing
155
156ngus is hosted on GitHub: https://github.com/blackm0re/ngus
157
158
159## Author
160
161Simeon Simeonov - sgs @ LiberaChat
162
163
164## [License](https://github.com/blackm0re/ngus/blob/master/LICENSE)
165
166Copyright (c) 2021, Simeon Simeonov
167All rights reserved.
168
169[Licensed](https://github.com/blackm0re/ngus/blob/master/LICENSE) under the
170GNU General Public License v3.0 or later.
171SPDX-License-Identifier: GPL-3.0-or-later