Added docker-compose file
This commit is contained in:
2
site/Makefile
Normal file
2
site/Makefile
Normal file
@@ -0,0 +1,2 @@
|
||||
library.so: library.c
|
||||
$(CC) $< -o $@ -shared -I../src/
|
||||
5
site/README
Normal file
5
site/README
Normal file
@@ -0,0 +1,5 @@
|
||||
This is a blog site. Ideally you wouldn't use any relative path names, but for
|
||||
portability reasons I'm assuming that swebs is being run in this directory.
|
||||
|
||||
Relative path names do work with docker, but relative path names scare me, and
|
||||
they should scare you too.
|
||||
22
site/domain.crt
Normal file
22
site/domain.crt
Normal file
@@ -0,0 +1,22 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDnTCCAoUCFGPzRWSwuJ0gy97miUAkPSMNdH38MA0GCSqGSIb3DQEBCwUAMIGK
|
||||
MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEzARBgNVBAcMCkNlZGFyIFBh
|
||||
cmsxDjAMBgNVBAoMBXN3ZWJzMQ4wDAYDVQQLDAVzd2ViczESMBAGA1UEAwwJTmF0
|
||||
ZSBDaG9lMSIwIAYJKoZIhvcNAQkBFhNuYXRlY2hvZTlAZ21haWwuY29tMB4XDTIy
|
||||
MDEyOTE3MjEzMFoXDTIyMDIyODE3MjEzMFowgYoxCzAJBgNVBAYTAlVTMQ4wDAYD
|
||||
VQQIDAVUZXhhczETMBEGA1UEBwwKQ2VkYXIgUGFyazEOMAwGA1UECgwFc3dlYnMx
|
||||
DjAMBgNVBAsMBXN3ZWJzMRIwEAYDVQQDDAlOYXRlIENob2UxIjAgBgkqhkiG9w0B
|
||||
CQEWE25hdGVjaG9lOUBnbWFpbC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
|
||||
ggEKAoIBAQC8l/c9+MDg32sxwx7xG8QIiUMNzsn7Ef9ZxKmOcj49crouYWhINaSB
|
||||
oMHt3obEZPYHs9n7uYLavlMiT8mQFpSejD7nsyQYQoyPwgSAb9MbSA6aJt4x+RAo
|
||||
54DnU4MpF1+pKoMOf5X5Kcs7UfR5I66YM2KXXKZUW96CIsAkmidfrpjPhdnhuafs
|
||||
5A5FVXD5B6PYUr4z7Z0CxEIvzIJzmoBCzTBwZEk0/p7WXsGkv0w7PCiWAMghO7WQ
|
||||
BdU5tQogbyQJckHS83puy13GjgJgM19v7R89g0GkHReNQ+2LlGkKZMZqDNVE3xuB
|
||||
x1/6dXeTHjZYOvVColLb5o+NFLHG3wQ/AgMBAAEwDQYJKoZIhvcNAQELBQADggEB
|
||||
AC/YmTpOOIkb26lzVE6Jbzi4a+0OTJXJBMT2RIgxSAzZ+ON8CZEzD1etCxTRrKVw
|
||||
dCjs9x+BQRpux/lw+YGlSBqNd/jc5YIACRaBEEc1nc/uMNMni1d2yPSbQlqiyS9o
|
||||
Q5aCz1urCQEXvuV4SCOWp84keyUzy1o/kCHSWj8Do67ah1rDf1g5MWc40gypU7FD
|
||||
ANHMUsPkxMlQreDtQ88/xwxYsOsmxwllR9WaL51L3VCa86PQrm4cX19ZYqRE/P8B
|
||||
WlKCBOkTMv2wX7Oa37/RVn+oWYWkrC5zwfVlToKSiM5vw5HztLbQoIVIBo5ye2cZ
|
||||
FC9F8qS0EGkrajXA5+hN0zQ=
|
||||
-----END CERTIFICATE-----
|
||||
27
site/domain.key
Normal file
27
site/domain.key
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEAvJf3PfjA4N9rMcMe8RvECIlDDc7J+xH/WcSpjnI+PXK6LmFo
|
||||
SDWkgaDB7d6GxGT2B7PZ+7mC2r5TIk/JkBaUnow+57MkGEKMj8IEgG/TG0gOmibe
|
||||
MfkQKOeA51ODKRdfqSqDDn+V+SnLO1H0eSOumDNil1ymVFvegiLAJJonX66Yz4XZ
|
||||
4bmn7OQORVVw+Qej2FK+M+2dAsRCL8yCc5qAQs0wcGRJNP6e1l7BpL9MOzwolgDI
|
||||
ITu1kAXVObUKIG8kCXJB0vN6bstdxo4CYDNfb+0fPYN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49BQXGe
|
||||
uPKvhuJMXom6zhfoCzGszlHBilbIzIWHpr9n7QXvGslXcL4/ioyNJCgt/Q9j8tcV
|
||||
/AhGNjCAIXLCjte5CiLZo9h0IW5+o4HH9jc4NWO8FrsHGecsY3k16hlU13YPP7U4
|
||||
HH7pAoGABvK/Dlb3djIwfiMTOK1EjvjJAkrSb6P4AQZea08GksVGfhTdsfkTbnhr
|
||||
n9WMf9p3IgAbmuHboJ89tPPTUVvDNrSSgWVtQ5rbREpXt05TAfT55STQFYOaSRG2
|
||||
FD0rK6CZrivPXgTpXWcy2zvfSseZZwEzVw23o4lwMCeVDI8+utg=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
17
site/library.c
Normal file
17
site/library.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <swebs/swebs.h>
|
||||
|
||||
int getResponse(Request *request, Response *response) {
|
||||
printf("%d\n", request->path.fieldCount);
|
||||
for (int i = 0; i < request->path.fieldCount; i++)
|
||||
printf("%s: %s\n", request->path.fields[i].var.data, request->path.fields[i].value.data);
|
||||
char *str = request->path.path.data;
|
||||
response->type = BUFFER;
|
||||
response->response.buffer.data = malloc(100);
|
||||
strcpy(response->response.buffer.data, str);
|
||||
response->response.buffer.len = strlen(str);
|
||||
return 200;
|
||||
}
|
||||
3
site/run.sh
Executable file
3
site/run.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
../build/swebs -p swebs.pid -s sitefile -o logs -b 100 -j2
|
||||
1
site/site/alldomains.html
Normal file
1
site/site/alldomains.html
Normal file
@@ -0,0 +1 @@
|
||||
<h1>This page shows up on all hostnames</h1>
|
||||
11
site/site/blog/README
Normal file
11
site/site/blog/README
Normal file
@@ -0,0 +1,11 @@
|
||||
If the user requests
|
||||
|
||||
/blog/2021-1-25
|
||||
|
||||
because the sitefile says
|
||||
|
||||
site/blog/
|
||||
|
||||
these 2 strings are appended into
|
||||
|
||||
site/blog//blog/2021-1-25
|
||||
1
site/site/blog/blog/2022-1-25.html
Normal file
1
site/site/blog/blog/2022-1-25.html
Normal file
@@ -0,0 +1 @@
|
||||
<p1>I have nothing to blog about</p1>
|
||||
3
site/site/easteregg.html
Normal file
3
site/site/easteregg.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>You found the easter egg!</h1>
|
||||
<img src="/egg.png">
|
||||
<p>There should be a picture of an egg here, but it doesn't show. go to 127.0.0.1:8000/egg.png to see it.</p>
|
||||
BIN
site/site/egg.png
Normal file
BIN
site/site/egg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
1
site/site/hello.html
Normal file
1
site/site/hello.html
Normal file
@@ -0,0 +1 @@
|
||||
<h1>Hello world!</h1>
|
||||
6
site/site/index.html
Normal file
6
site/site/index.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Welcome to my blog!</h1>
|
||||
|
||||
<h3>It's not very polished but it's certainly a website</h3>
|
||||
|
||||
<a href="blog/2022-1-25.html">2021-1-25</a>
|
||||
<a href="blog/forbidden">The forbidden blog post</a>
|
||||
@@ -1,4 +1,20 @@
|
||||
define transport TCP
|
||||
define port 8000
|
||||
|
||||
read .* /site/
|
||||
#define transport TLS
|
||||
define key domain.key
|
||||
define cert domain.crt
|
||||
define timeout 2000
|
||||
define library ./library.so
|
||||
|
||||
set host localhost:8000
|
||||
read / site/index.html
|
||||
read /hello site/hello.html
|
||||
throw /blog/forbidden 403
|
||||
read /blog/.* site/blog/
|
||||
#/blog/2021-1-25.html turns into site/blog//blog/2021-1-25.html
|
||||
linked /library
|
||||
set host 127.0.0.1:8000
|
||||
read / site/easteregg.html
|
||||
read /egg.png site/egg.png
|
||||
set host .*
|
||||
read /alldomains site/alldomains.html
|
||||
|
||||
Reference in New Issue
Block a user