|
|
# I bims 1 Container vong Linux her.
|
|
|
|
|
|
# lxc info
|
|
|
# lxc list
|
|
|
# lxc launch ubuntu:16.04 mycontainer
|
|
|
# lxc exec mycontainer /bin/bash
|
|
|
|
... | ... | @@ -8,4 +8,88 @@ https://github.com/lxc/lxd/blob/master/doc/index.md |
|
|
|
|
|
https://stgraber.org/2016/03/11/lxd-2-0-blog-post-series-012/
|
|
|
|
|
|
## nginx-Proxy & Port-Forwarding
|
|
|
|
|
|
von hand... irgendwie automatisieren? Ansible?
|
|
|
|
|
|
### Port Forwarding
|
|
|
|
|
|
```bash
|
|
|
container# apt install openssh-server # ssh
|
|
|
host# lxc list
|
|
|
+------------+---------+-----------------------+------+------------+----------------+
|
|
|
| NAME | STATUS | IPV4 | IPV6 | TYP | SCHNAPPSCHÜSSE |
|
|
|
+------------+---------+-----------------------+------+------------+----------------+
|
|
|
| ike-debian | RUNNING | 10.249.155.122 (eth0) | | PERSISTENT | 0 |
|
|
|
+------------+---------+-----------------------+------+------------+----------------+
|
|
|
| weimarnetz | RUNNING | 10.249.155.28 (eth0) | | PERSISTENT | 0 |
|
|
|
+------------+---------+-----------------------+------+------------+----------------+
|
|
|
// ssh auf port 22223 von außen geht an container 'weimarnetz' - siehe ip-addresse
|
|
|
host# iptables -A PREROUTING -i enp6s0f0 -p tcp -m tcp --dport 22223 -j DNAT --to-destination 10.249.155.28:22
|
|
|
host# netfilter save // regeln permanent speichern, liegen in /etc/iptables/rulesv.4
|
|
|
```
|
|
|
|
|
|
## nginx-Proxy + TLS (Let's Encrypt)
|
|
|
|
|
|
SSL muss auf dem Host terminiert werden - Zertifikate kann man mit `acme.sh` - [acme.sh](https://github.com/Neilpang/acme.sh) erstellen.
|
|
|
|
|
|
Beispiel Konfiguration:
|
|
|
|
|
|
```
|
|
|
$ cat /etc/nginx/sites-enabled/weimarnetz
|
|
|
server {
|
|
|
listen 80;
|
|
|
# ohne server_name geht nix, wir sortieren nach dem host header.
|
|
|
server_name hopglass.segfault.gq weimarnetz.segfault.gq;
|
|
|
|
|
|
# das ist für let's encrypt und acme.sh
|
|
|
# bei acme.sh --webroot /var/www/challenges als parameter mitgeben.
|
|
|
location /.well-known/acme-challenge/ {
|
|
|
root /var/www/challenges/;
|
|
|
}
|
|
|
|
|
|
# wenn man für einen host eine weiterleitung auf https haben möchte.
|
|
|
if ($host = "hopglass.segfault.gq") {
|
|
|
rewrite ^ https://$server_name$request_uri? redirect;
|
|
|
}
|
|
|
|
|
|
# der eigentliche proxy - wir geben den Host: header damit, dann der webserver dahinter verschiedene vhosts haben kann.
|
|
|
location / {
|
|
|
proxy_set_header Host $host;
|
|
|
# die eigentliche ip der anfrage wird mitgeliefert, damit kann z.b. im apache die richtige ip loggen.
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
# die requests gehen an die lokale ip des containers - mit lxc list schnell auffindbar.
|
|
|
proxy_pass http://10.249.155.28;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
# das gleiche nochmal in grün für tls
|
|
|
server {
|
|
|
# http2 hat einige vorzüge bezüglich geschwindigkeit.
|
|
|
listen 443 http2;
|
|
|
server_name hopglass.segfault.gq weimarnetz.segfault.gq;
|
|
|
|
|
|
# der pfad zum zertifikat mit acme.sh erstellbar z.b.
|
|
|
# acme.sh --issue -d weimarnetz.segfault.gq -d hopglass.segfault.gq --webroot /var/www/challenges
|
|
|
ssl_certificate /root/.acme.sh/weimarnetz.segfault.gq/fullchain.cer;
|
|
|
ssl_certificate_key /root/.acme.sh/weimarnetz.segfault.gq/weimarnetz.segfault.gq.key;
|
|
|
ssl_trusted_certificate /root/.acme.sh/weimarnetz.segfault.gq/ca.cer;
|
|
|
# braucht man für oscp-stapling (speeed!)
|
|
|
# https://blog.cloudflare.com/ocsp-stapling-how-cloudflare-just-made-ssl-30/
|
|
|
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
|
|
resolver_timeout 10s;
|
|
|
ssl_stapling on;
|
|
|
ssl_stapling_verify on;
|
|
|
|
|
|
# proxy wieder wie zuvor
|
|
|
location / {
|
|
|
proxy_set_header Host $host;
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
# immer noch plain http - hier kann auch eine variable rein, die angibt ob ssl oder nicht
|
|
|
proxy_pass http://10.249.155.28;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |