Webserver (PI)

Einführung

Erstellen eines Docker Containers für einen Webserver.

Voraussetzung

  • Raspberry Pi mit Raspbian OS
  • Docker
  • Docker-Compose
  • SWAG Setup

Container erstellen

Docker-Compose File:

version: "2"
services:
  my-web1:
    image: nginx:latest
    container_name: my-web1
    restart: always
    environment:
      #- VIRTUAL_HOST=www.mydomain.local,mydomain.local
      - VIRTUAL_PORT=8010
    expose:
      - 8010
    ports:
      - 8010:80
    volumes:
      - /sharedfolders/AppDataSD/web:/usr/share/nginx/html/ 

Reverse-Proxy Configs, die nach  /config/nginx/proxy-confs  kopiert werden müssen (z.B. my-web1.subdomain.conf):

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    #listen 80;
    #listen [::]:80;
    server_name maz-test.*;
    #include /config/nginx/ssl.conf;
    #client_max_body_size 0;
    location / {
        #include /config/nginx/proxy.conf;
        #resolver 127.0.0.11 valid=30s;
        #proxy_max_temp_file_size 2048m;

        proxy_pass  http://192.168.178.30:8010; 
        #index index.html;
    }
} 

Beispiel ‚index.html‘ in /sharedfolders/AppDataSD/web:

    <html>
        <head>
            <title>Welcome to our server</title>
            <style>
            body{
                font-family: Helvetica, Arial, sans-serif;
            }
            .message{
                width:330px;
                padding:20px 40px;
                margin:0 auto;
                background-color:#f9f9f9;
                border:1px solid #ddd;
            }
            center{
                margin:40px 0;
            }
            h1{
                font-size: 18px;
                line-height: 26px;
            }
            p{
                font-size: 12px;
            }
            </style>
        </head>
        <body>
            <div class="message">
                <h1>Welcome to our server (Rasp4_web)</h1>
                <p>The website is currently being setup under this address.</p>
                <p>For help and support, please contact: <a href="me@example.com">me@example.com</a></p>
            </div>
        </body>
    </html> 
Container starten:

docker-compose -f myweb1_docker-compose.yml up -d

Website prüfen. Browser starten und Domain eingeben.