OPNsense Forum

International Forums => German - Deutsch => Topic started by: lebernd on June 20, 2020, 09:55:23 pm

Title: 2-3 Probleme beim Wechsel von pfsense
Post by: lebernd on June 20, 2020, 09:55:23 pm
Hallo zusammen,

das Projekt steht schon lange an, macht langsam Fortschritte - jedoch zwei Sachen, die gerade viel Zeit brauchen und ja vielleicht hier jmd. weiß.

1) HAProxy: gibt es eine gute Anleitung, um sowas: https://github.com/PiBa-NL/pfsense-haproxy-package-doc/wiki/pfsense_2_3_haproxy_sni_plus_offloading_backends (https://github.com/PiBa-NL/pfsense-haproxy-package-doc/wiki/pfsense_2_3_haproxy_sni_plus_offloading_backends) zu machen?

Außerdem: bei pfsense kann man das Frontend einfach an WAN binden und selbst bei VDSL-Verbindung mit wechselnden IP-Adressen arbeitet HAProxy weiter.
Wenn ich es richtig verstanden habe, dann sollte ich bei opnsense eher das Frontend an 127.0.0.1:Port binden und eine Weiterleitung von WAN einrichten?
Die Frage ist hier: muss ich das Frontend zuerst als "realen Server" definieren?
Ich denke eine ähnliche Frage verbaut mir auch den Blick auf die Übertragung der Anleitung.
Wie reiche ich bei opnsense ein Frontend als (default-)Backend an ein anderes Frontend?

2) ich brauche eine funktionierende IPsec-Verbindung zu einer Fritzbox (site-to-site/PSK). Hat jmd. ein gutes How-To? Die Übertragung von pfsense-Einträgen ist da nicht 1:1 möglich.

Oder nehme ich einfach die funktionierenden Einstellungsdateien von der pfsense und umgehe die GUI?

Beste Grüße,
Bernd
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: micneu on June 20, 2020, 10:21:08 pm
VPN zwischen opnsense und fritzbox habe ich hier eine Anleitung
http://cloud.tapatalk.com/s/5eee6f9726267/IPSec_Fritzbox_config.pdf (http://cloud.tapatalk.com/s/5eee6f9726267/IPSec_Fritzbox_config.pdf)
Bei mir läuft das richtig gut


Gesendet von iPad mit Tapatalk Pro
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: lebernd on June 20, 2020, 10:38:22 pm
Oh prima - das probiere ich.
Vielen Dank!

Ja, schön - das hat geklappt.

Jemand wg. HAProxy eine Idee?
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: JeGr on June 25, 2020, 05:08:28 pm
> 1) HAProxy: gibt es eine gute Anleitung, um sowas: https://github.com/PiBa-NL/pfsense-haproxy-package-doc/wiki/pfsense_2_3_haproxy_sni_plus_offloading_backends zu machen?

Die Anleitung von PiBa ist selbst für pfSense relativ alt und out of date, da das Paket von pfSense inzwischen wesentlich neuer ist und Templates für 1-2 gebräuchliche Fälle mitbringt.

> Die Frage ist hier: muss ich das Frontend zuerst als "realen Server" definieren?

Was heißt für dich "realer Server"? Das Frontend will ja nur eine "IP" bzw. ein Interface. Du kannst da doch problemlos localhost/127.0.0.1 nutzen? "Besser" - wenn man auf localhost binden möchte - ist aber normalerweise, wenn man auf eine alternative 127er bindet. Dann musst du natürlich vorher die erstmal definieren, also bspw. als Alias-IP die 127.1.2.3 auf localhost zusätzlich binden und dann im Frontend eben das Frontend auf die 127.1.2.3 hören lassen. Warum nicht auf 127.0.0.1? Naja, wenn du die WebUI der Sense nicht änderst, wäre das ein potentieller Punkt, wo eine Fehlkonfiguration dir das WebUI der Sense ins Internet exposed. Muss wirklich nicht sein.

> Wie reiche ich bei opnsense ein Frontend als (default-)Backend an ein anderes Frontend?

OK... HÖ? Ein Frontend an eine Frontend? Was möchtest du denn damit erreichen? Das macht doch keinen Sinn ;)

Bitte ein wenig mehr Details, sonst schlecht zu helfen wenn man hellsehen soll :D

Grüße
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: lebernd on June 25, 2020, 08:03:41 pm
Hey @JeGr,

danke für deine Rückmeldung.

Quote
Was heißt für dich "realer Server"?
Ok, ich sollte nicht die Übersetzung von opnsense verwenden...  also auf jeden Fall nicht direkt das Backend, sondern die IP-Adressen auf oder hinter der Firewall...

Ja, die Anleitung ist alt, aber sie funktioniert immer noch... Das Problem ist Folgendes:

Ich habe eine WAN-IP (wechselnd, für diese Problem aber wohl egal) und also einen Port 443. Darauf soll sowohl 1-2 SNI Passthrough Verbindungen laufen (Nextcloud, CODE...) sowie für weitere Server (homeassistant, automx...) offloading erfolgen.

(Die pfsense Lösung ist so, dass auf dem Frontend ein default Backend definiert wird, das eigentlich auf einen offloading Server verweist. Alles was nicht per SNI abgezweigt wird, geht also zum default offloading server.)

Ich könnte gerne die config-Datei von pfsense posten... würde das was zusätzlich bringen?

Beste Grüße,
Bernd
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: lebernd on June 25, 2020, 08:30:26 pm
Ich poste mal noch die config - hoffentlich einigermaßen bereinigt - wg. dem Looping: Frontend auf Backend, das eigentlich ein Frontend ist...   :o

Code: [Select]
[2.4.5-RELEASE][admin@pfsense.domain.lan]/: cat /var/etc/haproxy/haproxy.cfg
# Automaticaly generated, dont edit manually.
# Generated on: 2020-06-19 04:14
global
maxconn 1000
log /var/run/log local0 info
stats socket /tmp/haproxy.socket level admin  expose-fd listeners
uid 80
gid 80
nbproc 1
nbthread 1
hard-stop-after 15m
chroot /tmp/haproxy_chroot
daemon
tune.ssl.default-dh-param 2048
log-send-hostname pfsense.domain.lan
server-state-file /tmp/haproxy_server_state
lua-load /var/etc/haproxy/luascript_acme-http01-webroot.lua

listen HAProxyLocalStats
bind 127.0.0.1:2200 name localstats
mode http
stats enable
stats refresh 10
stats admin if TRUE
stats show-legends
stats uri /haproxy/haproxy_stats.php?haproxystats=1
timeout client 5000
timeout connect 5000
timeout server 5000

# Frontend mit default backend und SNI
frontend sec-server
bind WAN-IP(changing every day):443 name WAN-IP(changing every day):443   
mode tcp
log global
timeout client 30000
tcp-request inspect-delay 5s
acl nextc-sni req.ssl_sni -i <nextcloud1-url>
acl is_sni_nextl req.ssl_sni -i <nextcloud1-url>
acl sni_code req.ssl_sni -i <code-url>
tcp-request content accept if { req.ssl_hello_type 1 }
use_backend nextcloud-debian_ipvANY  if  nextc-sni
use_backend nextcloud-debian_ipvANY  if  is_sni_nextl
use_backend code-office_ipvANY  if  sni_code
default_backend offload-server_ipvANY

# Offloading *Frontend*
frontend offload-server
bind 127.0.0.1:1443 name 127.0.0.1:1443   ssl crt-list /var/etc/haproxy/offload-server.crt_list 
bind /tmp/haproxy_chroot/offload-server.socket name unixsocket uid 80 accept-proxy   ssl crt-list /var/etc/haproxy/offload-server.crt_list
mode http
log global
option http-keep-alive
timeout client 30000
acl is_url_autodiscover var(txn.txnhost) -m beg -i autodiscover
acl is_url_autoconfig var(txn.txnhost) -m beg -i autoconfig
acl is_path_mail var(txn.txnpath) -m sub -i /mail/
acl is_path_autodiscover var(txn.txnpath) -m sub -i /autodiscover/
acl is_path_mobile var(txn.txnpath) -m sub -i /mobileconfig
acl is_url_automaten var(txn.txnhost) -m beg -i sub.homeautomaten.tdl
acl aclcrt_offload-server var(txn.txnhost) -m reg -i ^autoconfig\.domain1\.de(:([0-9]){1,5})?$
acl aclcrt_offload-server var(txn.txnhost) -m reg -i ^autoconfig\.domain2\.net(:([0-9]){1,5})?$
acl aclcrt_offload-server var(txn.txnhost) -m reg -i ^autodiscover\.domain1\.de(:([0-9]){1,5})?$
acl aclcrt_offload-server var(txn.txnhost) -m reg -i ^autodiscover\.domain2\.net(:([0-9]){1,5})?$
acl aclcrt_offload-server var(txn.txnhost) -m reg -i ^sub\.homeauto\.de(:([0-9]){1,5})?$
http-request set-var(txn.txnhost) hdr(host)
http-request set-var(txn.txnpath) path
use_backend automx_ipvANY  if  is_url_autodiscover is_path_autodiscover aclcrt_offload-server
use_backend automx_ipvANY  if  is_url_autoconfig is_path_mail aclcrt_offload-server
use_backend automx_ipvANY  if  is_url_autodiscover is_path_mobile aclcrt_offload-server
use_backend automaten_ipvANY  if  is_url_automaten aclcrt_offload-server

# Port 80 Frontend
frontend http-automx
bind WAN-IP(changing every day):80 name WAN-IP(changing every day):80   
mode http
log global
option log-separate-errors
option httplog
option http-keep-alive
timeout client 30000
acl is_mail var(txn.txnpath) -m sub -i /mail/
acl is_hostname var(txn.txnhost) -m beg -i autoconfig
acl is_url_acme var(txn.txnpath) -m beg -i /.well-known/acme-challenge/
http-request set-var(txn.txnpath) path
http-request set-var(txn.txnhost) hdr(host)
http-request use-service lua.acme-http01  if  METH_GET is_url_acme
use_backend automx_ipvANY  if  is_hostname is_mail

backend nextcloud-debian_ipvANY
mode tcp
id 103
log global
option log-health-checks
timeout connect 30000
timeout server 30000
retries 3
acl nextcACL req.ssl_sni -i <nextcloud1-url>
acl nextl req.ssl_sni -i <nextcloud2-url>
tcp-request content accept if { req.ssl_hello_type 1 }
server nextcloud DMZ-IP:443 id 104 check inter 1000 

backend code-office_ipvANY
mode tcp
id 105
log global
timeout connect 30000
timeout server 30000
retries 3
acl office-dmzACL req.ssl_sni -m sub -i <code-url>
tcp-request content accept if { req.ssl_hello_type 1 }
server office DMZ-IP:443 id 106 check inter 1000 

# default Backend
backend offload-server_ipvANY
mode tcp
id 108
log global
timeout connect 30000
timeout server 30000
retries 3
server frontend-offload /offload-server.socket send-proxy-v2-ssl-cn id 109 check inter 5000 

backend automx_ipvANY
mode http
id 100
log global
option log-health-checks
timeout connect 30000
timeout server 30000
retries 3
option httpchk OPTIONS /
server automx-back MAIL-IP:80 id 107 check inter 1000 

backend automaten_ipvANY
mode http
id 110
log global
option log-health-checks
timeout connect 30000
timeout server 30000
retries 3
server automaten-back AUTOMATEN-IP:8123 id 107 check inter 1000 

Wenn ich es richtig sehe, dann läuft es auf pfsense über ein extra socket ?
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: JeGr on June 26, 2020, 12:31:47 am
Ich verstehe die Logik nicht ganz, warum du nicht alles schlicht gleich behandelst via SNI? Kann das aber auf die Schnelle (und Späte) auch aus der Konfig nicht ganz klar erkennen. Da wird ein zwei Mal ein Path Match gemacht statt ein host/url match. Aber ich sehe da nur autoconfig/autodiscover domains und die kann man doch problemlos einfach via SNI aufs entsprechende Backend schieben?

Verstehe daher nicht ganz warum du es so komplex aufdröseln willst :) Außer dem ACME Request, der nur auf einem Port 80 Frontend sinnvoll ist, und einen Path ACL bräuchte, ginge das doch ansonsten über die unterschiedlichen Domains/Subdomains?
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: lebernd on June 26, 2020, 06:54:06 am
Quote
Ich verstehe die Logik nicht ganz, warum du nicht alles schlicht gleich behandelst via SNI?
Dann habe ich es auch nicht richtig formuliert. Ich habe eher eine Frage erwartet wie: warum nicht alles über ein Offloading Frontend :-)

Also mein Problem/ Wunsch: "ein" Frontend (Port 443) mit TCP-modus UND https offloading...
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: JeGr on June 29, 2020, 03:30:59 pm
> Also mein Problem/ Wunsch: "ein" Frontend (Port 443) mit TCP-modus UND https offloading...

Gut, das wäre auch mein Ansatz so viel wie möglich mit dem gleichen Frontend abzudecken. Und es scheitert jetzt woran?

Hast du BTW sicherheitshalber deine WebUI auf nen anderen Port gelegt?
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: lebernd on June 30, 2020, 11:38:33 pm
Naja, es scheitert daran, dass ein frontend eigentlich entweder tcp ODER offloading macht. Ich jedoch ein UND mir wünsche...

Oder anders: dass ich zwar ein tcp frontend hinbekomme, ich jedoch dann nicht weiß, wie weiter. Egal wie alt, das fand ich das schöne am pfsense Tutorial/ how-to. Die ganzen Loop Verdrehungen kommen ja nur daher, weil es eigentlich ein ODER ist.
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: JeGr on July 03, 2020, 11:24:53 am
Warum magst du denn auf dem tcp/443 Frontend "entweder tcp oder offload" je nach Domain machen? Macht doch keinen wirklichen Sinn bzw. bringt keinen wahnsinnigen Mehrwert? Wäre doch einfacher schlicht alle Domains via Offloading und Zertifikat auf der Sense zu machen statt das eine direkt auf der Kiste und das andere doch wieder mit Offload? Daher die Frage warum überhaupt das unterschiedlich gemacht werden will/soll?
Title: Re: 2-3 Probleme beim Wechsel von pfsense
Post by: lebernd on August 06, 2020, 10:04:08 am
Hallo @JeGr

so, nach dem Urlaub habe ich mich wieder daran gemacht und nun deinen Rat befolgt und mache das eben nun alles über Offloading. Selbst mein Collabora Code läuft nun.
Es gibt für Nextcloud und HAproxy eine ganz gute Anleitung von https://schulnetzkonzept.de/opnsense (https://schulnetzkonzept.de/opnsense)
Bis Code lief hat es noch ein wenig gedauert - auch wenn es dann ganz einfach ist, wenn man die Lösung gefunden hat...

Offloading hat ja tatsächlich den Vorteil, dass LE zentral und automatisch auf opnsense läuft.

Dir nochmal danke fürs einklinken! Im englischen Forum ist es ja manchmal ohrenbetäubend leise...

Beste Grüße, Bernd