Skip to content

Latest commit

 

History

History
139 lines (110 loc) · 3.22 KB

File metadata and controls

139 lines (110 loc) · 3.22 KB

HTTP server

You need to have a http server to serve your rpm repositories

For this documentation, we are going to use an Apache server.

But feel free to use your own HTTP server.

Install Apache server

For debian:

sudo apt-get install apache2

Create certificat

For HTTPS, you need to have a certificat.

sudo openssl req -new -x509 -days 365 -nodes -out /etc/ssl/certs/yomo.crt -keyout /etc/ssl/private/yomo.key

output:

Generating a 2048 bit RSA private key
.................+++
.............+++
writing new private key to 'yomo.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:FR
State or Province Name (full name) [Some-State]:France
Locality Name (eg, city) []:Vannes
Organization Name (eg, company) [Internet Widgits Pty Ltd]:IoT.bzh
Organizational Unit Name (eg, section) []:IoTVannes
Common Name (e.g. server FQDN or YOUR name) []:XXXX
Email Address []:ronan.lemartret@iot.bzh
sudo chmod 440 /etc/ssl/certs/yomo.crt

Configure apache server

Configure some parameter using environment variables:

export USER_EMAIL="ronan.lemartret@iot.bzh"
export YOMO_SRV_DIR="/home/devel/share/http_svr/data"
export YOMO_SRV_LOG="/home/devel/share/http_svr/log"

Make the variable pointing to the content location persistent:

cat << EOF >> ~/.bashrc

export YOMO_SRV_DIR=${YOMO_SRV_DIR}
export YOMO_SRV_LOG=${YOMO_SRV_LOG}
EOF

Create the server content location directory and configuration files:

sudo mkdir -p ${YOMO_SRV_DIR} ${YOMO_SRV_LOG}

sudo bash -c "cat << EOF > /etc/apache2/sites-available/http_yomo.conf
<VirtualHost *:80>
    ServerAdmin ${USER_EMAIL}
    ServerName http_yomo
    DocumentRoot ${YOMO_SRV_DIR}
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory ${YOMO_SRV_DIR}>
        Options Indexes MultiViews
        AllowOverride None
        Require all granted
    </Directory>
    ErrorLog ${YOMO_SRV_LOG}/error.log
    LogLevel warn
</VirtualHost>
EOF"

sudo bash -c "cat << EOF > /etc/apache2/sites-available/https_yomo.conf
<VirtualHost *:443>
    ServerAdmin ${USER_EMAIL}
    ServerName https_yomo
    DocumentRoot ${YOMO_SRV_DIR}
    <Directory />
        SSLRequireSSL
        Options FollowSymLinks
        AllowOverride None
    </Directory>

  ServerSignature Off
  LogLevel info

  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/yomo.crt
  SSLCertificateKeyFile /etc/ssl/private/yomo.key

    <Directory ${YOMO_SRV_DIR}>
        Options Indexes MultiViews
        AllowOverride None
        Require all granted
    </Directory>
    ErrorLog ${YOMO_SRV_LOG}/error.log
    LogLevel warn
</VirtualHost>
EOF"

Remove default configuration file:

sudo rm /etc/apache2/sites-enabled/000-default.conf

Submit the config and restart the server:

sudo a2ensite http_yomo.conf
sudo a2ensite https_yomo.conf
sudo a2enmod ssl
sudo systemctl restart apache2