SERVER#3 LXC

Web Shell
Webmin

Resources and references

Create inithooks configuration (/root/wp1.conf)

cat <<EOF > /root/wp1.conf
export ROOT_PASS=secretrootpass
export DB_PASS=secretmysqlpass
export APP_PASS=secretadminwppass
export APP_EMAIL=admin@example.com
export APP_DOMAIN=www.example.com
export HUB_APIKEY=SKIP
export SEC_UPDATES=FORCE
EOF

Create LXC container

lxc-create -n wp1 -f /etc/lxc/bridge.conf -t turnkey -- wordpress -i /root/wp1.conf

Start the container in the background

lxc-start -n wp1 -d
Note: options have changed since v13.0

Create inithooks configuration (/root/wp1.conf)

cat <<EOF > /root/wp1.conf
export ROOT_PASS=secretrootpass
export DB_PASS=secretmysqlpass
export APP_PASS=secretadminwppass
export APP_EMAIL=admin@example.com
export APP_DOMAIN=www.example.com
export HUB_APIKEY=SKIP
export SEC_UPDATES=FORCE
EOF

Create LXC container

lxc-create -n wp1 -f /etc/lxc/natbridge.conf -t turnkey -- wordpress -i /root/wp1.conf -v 14.2-jessie

Start the container in the background

lxc-start -n wp1 -d

Configure proxying web requests for domain to container

nginx-proxy --domain www.example.com --name wp1

Expose the container SSH service

ipaddr=$(host wp1 | cut -d " " -f 4)
iptables-nat add 2222 $ipaddr:22

Stop proxying web requests for domain to container

nginx-proxy --remove -d www.example.com -n wp1

Stop the container

lxc-stop -n wp1

Destroy the container

lxc-destroy -f -n wp1
Note: options have changed since v13.0

Usage: LTC LXC Template

TurnKey LXC Template Syntax: appname [options]
 
Arguments::
 
    appname          Appliance name (e.g., core)
 
Options::
 
    -a --arch=       Appliance architecture (default: hosts architecture)
    -v --version=    Appliance version (default: 14.0-jessie)
    -x --aptproxy=   Address of APT Proxy (e.g., http://192.168.121.1:3142)
 
    -i --inithooks=  Path to inithooks.conf (default: /root/inithooks.conf)
                     Reference: http://www.turnkeylinux.org/docs/inithooks
 
       --rootfs=     Path to root filesystem (default: $path/$name/rootfs)
    -c --clean       Clean the cache i.e. purge all downloaded appliance images
 
Required options (passed automatically by lxc-create):
 
    -n --name=       container name ($name)
    -p --path=       container path_name ($path/$name)
 
Example usage::
 
    lxc-create -n core -f /etc/lxc/bridge.conf -t turnkey -- core -i /root/inithooks.conf

Usage: nginx-proxy

nginx-proxy version 2.3: GNU General Public License version 3
Create site configuration to proxy requests destined for domain to host

Syntax: nginx-proxy [-d|--domain] domain [-n|--name] host [-r|--remove]

Arguments::

    domain           source domain (fqdn)
    host             destination host name

Options::

    -h --help        usage: display this message
    -d --domain      source domain
    -n --name        host name
    -l --list        list domains and hosts
    -r --remove      remove a proxy from domain(s) to host
    -t --template    use alternate template
    -c --check       indicate if any changes would be made

Examples::

    # create a proxy from domain 'www.example.com' to host 'wordpress' 
    nginx-proxy --domain www.example.com --name wordpress

    # remove a proxy from domain 'www.example.com' to host 'wordpress'
    nginx-proxy --remove -d www.example.com -n wordpress

    # remove all proxies for host 'wordpress'
    nginx-proxy --remove -d all -n wordpress

    # run in check-mode making no changes, but indicating what would be changed
    nginx-proxy --check -d www.example.com -n wordpress

Exit Codes::

        0    no changes were made or would have been made (check-mode)
        1    changes were made or would have been made (check-mode)
        2    fatal error prevented command completion

Notes::

    # also supports the v13.0 syntax
    nginx-proxy www.example.com wordpress

    # uses Jinja2 style templates for variable substitution
    # default template (preconfigured for ports 80, 443)
    /etc/nginx/templates/default.j2

    # lxc template (preconfigured for ports 80, 443, 12320, 12321, 12322)
    /etc/nginx/templates/container.j2