Lightweight c++ web server for archlinux with ftp (available in docker container)
makepkg -sif
docker build --rm -t webserver .
- Create google account with new email.
- Go to your new account's settings.
- Go to
Security
tab. - Enable 2-step verification.
- After that you should see entry called
App passwords
, that's what we need: go there. - Tap on
Select app
field. - Choose entry
Other (custom name)
from dropdown menu. - Call it somehow. For example, I used label
smtp
. - Press button called
Generate
. - Here you should see key that looks like this
wagy hdfr jwar ydyp
. - Copy it.
- Then go to command prompt and enter commands above, replacing
<account>
with your gmail account name and<password>
with the key, you just copied.
First you need generate ssl certificates (only once)
sudo mkdir -p /srv/certs/
cd /srv/certs/
echo -e "CASUBJ=\"/C=UA/ST=Ukraine/L=Zakarpattia/O=imperzer0/CN=CAwebserver\";\n\
CRTSUBJ=\"/C=UA/ST=Ukraine/L=Zakarpattia/O=imperzer0/CN=CRTwebserver\";\n\
# Generate CA (Certificate Authority)\n\
openssl genrsa -out ca.key 2048;\n\
openssl req -new -x509 -days 365 -key ca.key -out ca.pem -subj \$CASUBJ;\n\
# Generate server certificate\n\
openssl genrsa -out key.pem 2048;\n\
openssl req -new -key key.pem -out csr.pem -subj \$CRTSUBJ;\n\
openssl x509 -req -days 365 -in csr.pem -CA ca.pem -CAkey ca.key -set_serial 01 -out cert.pem;" \
>generator.bash && chmod +x generator.bash && bash generator.bash
Then navigate to website
directory and run commands
sudo mkdir -p /srv/webserver/
cd /srv/webserver/
webserver --tls /srv/certs/ --email="<account>@gmail.com" --email-password="<password>"
Open up terminal (in website
directory) and run commands
docker volume create webserver_certificates
docker volume create webserver_data
docker volume create webserver_etc
docker run --network=host -v webserver_certificates:/srv/certs \
-v webserver_data:/srv/webserver \
-v webserver_etc:/etc --name webserver -it webserver \
--email="<account>@gmail.com" --email-password="<password>"
webserver
is flexible application.
If you want to implement custom functionality, do so in config.cpp
.
Follow the guidelines in the comments to configure it properly.
Avoid editing other files to keep the application stable.