Not necessary, just leave the port in the server settings blank.
Thank you. yes it is confusing due to my lack of knowledge. I'm going to redo the diagram and post it again based on these latest comments.Yes, i do not intend to load balance. You already understand that better than I do.I didn't realize I could keep using my previous setup you helped me with. I will continue with that. I was about to go through your whole tutorial from scratch, and just remove that redirect rule.
The guide below lists only those options that need to be changed, all other options need to be left untouched in their default state.1. Create the real servers 1.1 TCP_SERVICE1_server: IP, Port, SSL unticked 1.2 TCP_SERVICE2_server: IP, Port, SSL unticked2. Create the backends 2.1 TCP_SERVICE1_backend Mode: TCP Servers: TCP_SERVICE1_server 2.2 TCP_SERVICE2_backend Mode: TCP Servers: TCP_SERVICE2_server3. Create the conditions 3.1 TCP_SSL_condition Condition type: SSL Hello Type SSL Hello Type: 1 - client hello 3.2 TCP_SERVICE1_condition Condition type: SNI TLS extension matches (TCP request content inspection) SNI Matches: service1.domain.tld 3.3 TCP_SERVICE2_condition Condition type: SNI TLS extension matches (TCP request content inspection) SNI Matches: service2.domain.tld4. Create the rules 4.1 TCP_RequestInspectDelay_rule Select conditions: Nothing selected Execute function: tcp-request inspect delay TCP inspection delay: 5s 4.2 TCP_RequestContentAccept_rule Select conditions: TCP_SSL_condition Logical operator for conditions: none Execute function: tcp-request content accept 4.3 TCP_SERVICE1_rule Select conditions: TCP_SERVICE1_condition Logical operator for conditions: none Execute function: Use specified Backend Pool Use backend pool: TCP_SERVICE1_backend 4.4 TCP_SERVICE2_rule Select conditions: TCP_SERVICE2_condition Logical operator for conditions: none Execute function: Use specified Backend Pool Use backend pool: TCP_SERVICE2_backend5. Edit the SNI_frontend Note: This step assumes that you are not following my whole tutorial. However you have to at least finish the following steps of my tutorial: - Part 4: everything - Part 5: step 1-3 and step 10 (only create the SNI_frontend but without a Default Backend Pool) The exact order of the rules below is very important here! The "TCP_RequestInspectDelay_rule" always has to be the first rule. The "TCP_RequestContentAccept_rule" always has to be the second rule. 5.1 Add the rules to the SNI_frontend in the following order: Select Rules: 1. TCP_RequestInspectDelay_rule 2. TCP_RequestContentAccept_rule 3. TCP_SERVICE1_rule 4. TCP_SERVICE2_rule
## Automatically generated configuration.# Do not edit this file manually.#global uid 80 gid 80 chroot /var/haproxy daemon stats socket /var/run/haproxy.socket group proxy mode 775 level admin nbthread 4 hard-stop-after 60s no strict-limits maxconn 10000 tune.ssl.default-dh-param 4096 spread-checks 2 tune.bufsize 16384 tune.lua.maxmem 0 log 0.0.0.0 local0 info lua-prepend-path /tmp/haproxy/lua/?.luadefaults log global option redispatch -1 maxconn 5000 timeout client 30s timeout connect 30s timeout server 30s retries 3 default-server init-addr last,libc default-server maxconn 5000# autogenerated entries for ACLs# autogenerated entries for config in backends/frontends# autogenerated entries for stats# Frontend: SNI_frontend ()frontend SNI_frontend bind 0.0.0.0:443 name 0.0.0.0:443 mode tcp # logging options option tcplog # ACL: TCP_SSL_condition acl acl_644c56b6785678.47181279 req.ssl_hello_type 1 # ACL: NoSSL_condition acl acl_644d62959d73a1.59974462 ssl_fc # ACL: server1_condition acl acl_644c5700ee7657.09485748 req.ssl_sni -m sub -i domain1.com # ACL: server2_condition acl acl_644c5719768e71.87060950 req.ssl_sni -i domain2.com # ACTION: TCP_RequestInspectDelay_rule # NOTE: actions with no ACLs/conditions will always match tcp-request inspect-delay 5s # ACTION: TCP_RequestContentAccept_rule tcp-request content accept if acl_644c56b6785678.47181279 # ACTION: server1_rule use_backend server1_backend if !acl_644d62959d73a1.59974462 acl_644c5700ee7657.09485748 # ACTION: server2_rule use_backend server2_backend if !acl_644d62959d73a1.59974462 acl_644c5719768e71.87060950# Frontend: HTTP_frontend ()frontend HTTP_frontend bind 0.0.0.0:80 name 0.0.0.0:80 mode tcp # logging options option tcplog # ACL: NoSSL_condition acl acl_644d62959d73a1.59974462 ssl_fc # ACL: server2_condition acl acl_644c5719768e71.87060950 req.ssl_sni -i domain2.com # ACL: server1_condition acl acl_644c5700ee7657.09485748 req.ssl_sni -m sub -i domain1.com acl acl_644c56b6785678.47181279 req.ssl_hello_type 1 # ACTION: server2_rule use_backend server2_backend if !acl_644d62959d73a1.59974462 acl_644c5719768e71.87060950 # ACTION: server1_rule use_backend server1_backend if !acl_644d62959d73a1.59974462 acl_644c5700ee7657.09485748 # ACTION: TCP_RequestInspectDelay_rule # NOTE: actions with no ACLs/conditions will always match tcp-request inspect-delay 5s # ACTION: TCP_RequestContentAccept_rule tcp-request content accept if acl_644c56b6785678.47181279# Backend: server1_backend ()backend server1_backend # health checking is DISABLED mode tcp balance source # stickiness stick-table type ip size 50k expire 30m stick on src server server1_server 192.168.1.234 # Backend: server2_backend ()backend server2_backend # health checking is DISABLED mode tcp balance source # stickiness stick-table type ip size 50k expire 30m stick on src server server2_server 192.168.1.231 # statistics are DISABLED
I was reading this link:https://blog.entrostat.com/routing-multiple-domains-using-haproxy-http-and-https-ssl/And it says:QuoteWhat you'll notice here is that I bind to port 80 using mode http but I bind to port 443 using mode tcp. This is to avoid the need for certificates on the 443 bind. Basically, what I'm doing here is routing 443 to a host and I expect that host to have the certificate set up.Which makes me wonder do I need separate servers per port? So 4 total...so that I can use different modes for each port?
What you'll notice here is that I bind to port 80 using mode http but I bind to port 443 using mode tcp. This is to avoid the need for certificates on the 443 bind. Basically, what I'm doing here is routing 443 to a host and I expect that host to have the certificate set up.
When you are done post the haproxy config export.But please in a codebox, no need to upload the file.And don't forget to remove sensitive info.
## Automatically generated configuration.# Do not edit this file manually.#global uid 80 gid 80 chroot /var/haproxy daemon stats socket /var/run/haproxy.socket group proxy mode 775 level admin nbthread 4 hard-stop-after 60s no strict-limits maxconn 10000 tune.ssl.default-dh-param 4096 spread-checks 2 tune.bufsize 16384 tune.lua.maxmem 0 log 0.0.0.0 local0 info lua-prepend-path /tmp/haproxy/lua/?.luadefaults log global option redispatch -1 maxconn 5000 timeout client 30s timeout connect 30s timeout server 30s retries 3 default-server init-addr last,libc default-server maxconn 5000# autogenerated entries for ACLs# autogenerated entries for config in backends/frontends# autogenerated entries for stats# Frontend: SNI_frontend ()frontend SNI_frontend bind 0.0.0.0:443 name 0.0.0.0:443 mode tcp # logging options option tcplog # ACL: TCP_SSL_condition acl acl_644c56b6785678.47181279 req.ssl_hello_type 1 # ACL: TCP_server1_condition acl acl_644c5700ee7657.09485748 req.ssl_sni -m sub -i domain1.com # ACL: TCP_server2_condition acl acl_644c5719768e71.87060950 req.ssl_sni -i domain2.com # ACTION: TCP_RequestInspectDelay_rule # NOTE: actions with no ACLs/conditions will always match tcp-request inspect-delay 5s # ACTION: TCP_RequestContentAccept_rule tcp-request content accept if acl_644c56b6785678.47181279 # ACTION: TCP_SERVICE1_rule use_backend TCP_SERVICE1_backend if acl_644c5700ee7657.09485748 # ACTION: TCP_SERVICE2_rule use_backend TCP_SERVICE2_backend if acl_644c5719768e71.87060950# Frontend: HTTP_frontend ()frontend HTTP_frontend bind 0.0.0.0:80 name 0.0.0.0:80 mode tcp # logging options option tcplog # ACL: http_server1_condition acl acl_6457247ca14984.71641345 hdr_sub(host) -i domain1.com # ACL: NoSSL_condition acl acl_644d62959d73a1.59974462 ssl_fc # ACL: http_server2_condition acl acl_64572496aeac32.73416688 hdr_sub(host) -i domain2.com # ACTION: http_server1_rule use_backend TCP_SERVICE1_backend if acl_6457247ca14984.71641345 !acl_644d62959d73a1.59974462 # ACTION: http_server2_rule use_backend TCP_SERVICE2_backend if acl_64572496aeac32.73416688 !acl_644d62959d73a1.59974462# Backend: TCP_SERVICE1_backend ()backend TCP_SERVICE1_backend # health checking is DISABLED mode tcp balance source # stickiness stick-table type ip size 50k expire 30m stick on src server TCP_SERVICE1_server 192.168.1.234 # Backend: TCP_SERVICE2_backend ()backend TCP_SERVICE2_backend # health checking is DISABLED mode tcp balance source # stickiness stick-table type ip size 50k expire 30m stick on src server TCP_SERVICE2_server 192.168.1.231 # statistics are DISABLED
Hello sir,I followed your guide and everything worked for the past year. However, today for some reason, my server doesn't respond to my domain anymore. I have adguard and truenas setup so when I run those command ad.xxxx.xxxx, it resolved. However, if I just run mydomain.xxx then it doesn't resolve to my public IP address anymore.May I ask what maybe the problem?Thank you so much for your time sir.
logo root@localdomainLobbyReportingSystemInterfacesFirewallVPNServicesACME ClientAdguardhomeCaptive PortalDHCPv4DHCPv6Dnsmasq DNSDynamic DNSFreeRADIUSHAProxySettingsStatisticsMaintenanceLog FileConfig ExportIntrusion DetectionMonitNetwork TimeOpenDNSUnbound DNSWake on LANWeb ProxyZenarmorPowerHelp Services: HAProxy: Config Export Config Export Config Diff## Automatically generated configuration.# Do not edit this file manually.#global uid 80 gid 80 chroot /var/haproxy daemon stats socket /var/run/haproxy.socket group proxy mode 775 level admin nbthread 6 hard-stop-after 60s no strict-limits maxconn 10000 tune.ssl.default-dh-param 4096 spread-checks 2 tune.bufsize 16384 tune.lua.maxmem 0 log /var/run/log local0 info lua-prepend-path /tmp/haproxy/lua/?.luadefaults log global option redispatch -1 maxconn 5000 timeout client 30s timeout connect 30s timeout server 30s retries 3 default-server init-addr last,libc default-server maxconn 5000# autogenerated entries for ACLs# autogenerated entries for config in backends/frontends# autogenerated entries for stats# Frontend: 0_SNI_frontend (Listening on 0.0.0.0:80, 0.0.0.0:443)frontend 0_SNI_frontend bind 0.0.0.0:443 name 0.0.0.0:443 bind 0.0.0.0:80 name 0.0.0.0:80 mode tcp default_backend SSL_backend # logging options# Frontend: 1_HTTP_frontend (Listening on 127.4.4.3:80)frontend 1_HTTP_frontend bind 127.4.4.3:80 name 127.4.4.3:80 accept-proxy mode http option http-keep-alive option forwardfor # logging options # ACL: NoSSL_condition acl acl_630c2xxx9944 ssl_fc # ACTION: HTTPtoHTTPS_rule http-request redirect scheme https code 301 if !acl_630c25xxx249944# Frontend: 1_HTTPS_frontend (Listening on 127.4.4.3:443)frontend 1_HTTPS_frontend http-response set-header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" bind 127.4.4.3:443 name 127.4.4.3:443 accept-proxy ssl curves secp384r1 no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES256-GCM-SHA384 ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 alpn h2,http/1.1 crt-list /tmp/haproxy/ssl/630c280xxx7137226.certlist mode http option http-keep-alive option forwardfor timeout client 15m # logging options # ACL: LOCAL_SUBDOMAINS_SUBNETS_condition acl acl_630c2982907624.21524463 src 20.xxx.0/24 20xxx0/24 20xxx.0/24 # ACTION: LOCAL_SUBDOMAINS_map-rule use_backend %[req.hdr(host),lower,map_dom(/tmp/haproxy/mapfiles/630c2909dfxxx.10265915.txt)] if acl_630c2xxx7624.21524463 # ACTION: PUBLIC_SUBDOMAINS_map-rule # NOTE: actions with no ACLs/conditions will always match use_backend %[req.hdr(host),lower,map_dom(/tmp/haproxy/mapfiles/630c262xxx9c50.82551607.txt)] # Backend: SSL_backend ()backend SSL_backend # health checking is DISABLED mode tcp balance source # stickiness stick-table type ip size 50k expire 30m stick on src server SSL_server 127.4.4.3 send-proxy-v2 check-send-proxy# Backend: opnsense_backend ()backend opnsense_backend # health checking is DISABLED mode http balance source # stickiness stick-table type ip size 50k expire 30m stick on src http-reuse safe server opnsense_server 20.14.0.1:55443 ssl verify none# Backend: truenas_backend ()backend truenas_backend # health checking is DISABLED mode http balance source # stickiness stick-table type ip size 50k expire 30m stick on src http-reuse safe server truenas_server 20.xxx.4 ssl verify none# Backend: proxmox_backend ()backend proxmox_backend # health checking is DISABLED mode http balance source # stickiness stick-table type ip size 50k expire 30m stick on src http-reuse safe server proxmox_server 20.xxx47:8xxx6 ssl verify none# Backend: ad_backend ()backend ad_backend # health checking is DISABLED mode http balance source # stickiness stick-table type ip size 50k expire 30m stick on src http-reuse safe server ad_server 20.xxx.1:56xxx43 ssl verify none# Backend (DISABLED): proxmox_backend_1 ()# Backend (DISABLED): truenas_backend_1 ()# statistics are DISABLEDOPNsense (c) 2014-2023 Deciso B.V.
Hello sir,Thank you for getting back to me.Attached is my HAProxy config Code: [Select]logo root@localdomainLobbyReportingSystemInterfacesFirewallVPNServicesACME ClientAdguardhomeCaptive PortalDHCPv4DHCPv6Dnsmasq DNSDynamic DNSFreeRADIUSHAProxySettingsStatisticsMaintenanceLog FileConfig ExportIntrusion DetectionMonitNetwork TimeOpenDNSUnbound DNSWake on LANWeb ProxyZenarmorPowerHelp Services: HAProxy: Config Export Config Export Config Diff## Automatically generated configuration.# Do not edit this file manually.#global uid 80 gid 80 chroot /var/haproxy daemon stats socket /var/run/haproxy.socket group proxy mode 775 level admin nbthread 6 hard-stop-after 60s no strict-limits maxconn 10000 tune.ssl.default-dh-param 4096 spread-checks 2 tune.bufsize 16384 tune.lua.maxmem 0 log /var/run/log local0 info lua-prepend-path /tmp/haproxy/lua/?.luadefaults log global option redispatch -1 maxconn 5000 timeout client 30s timeout connect 30s timeout server 30s retries 3 default-server init-addr last,libc default-server maxconn 5000# autogenerated entries for ACLs# autogenerated entries for config in backends/frontends# autogenerated entries for stats# Frontend: 0_SNI_frontend (Listening on 0.0.0.0:80, 0.0.0.0:443)frontend 0_SNI_frontend bind 0.0.0.0:443 name 0.0.0.0:443 bind 0.0.0.0:80 name 0.0.0.0:80 mode tcp default_backend SSL_backend # logging options# Frontend: 1_HTTP_frontend (Listening on 127.4.4.3:80)frontend 1_HTTP_frontend bind 127.4.4.3:80 name 127.4.4.3:80 accept-proxy mode http option http-keep-alive option forwardfor # logging options # ACL: NoSSL_condition acl acl_630c2xxx9944 ssl_fc # ACTION: HTTPtoHTTPS_rule http-request redirect scheme https code 301 if !acl_630c25xxx249944# Frontend: 1_HTTPS_frontend (Listening on 127.4.4.3:443)frontend 1_HTTPS_frontend http-response set-header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" bind 127.4.4.3:443 name 127.4.4.3:443 accept-proxy ssl curves secp384r1 no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES256-GCM-SHA384 ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 alpn h2,http/1.1 crt-list /tmp/haproxy/ssl/630c280xxx7137226.certlist mode http option http-keep-alive option forwardfor timeout client 15m # logging options # ACL: LOCAL_SUBDOMAINS_SUBNETS_condition acl acl_630c2982907624.21524463 src 20.xxx.0/24 20xxx0/24 20xxx.0/24 # ACTION: LOCAL_SUBDOMAINS_map-rule use_backend %[req.hdr(host),lower,map_dom(/tmp/haproxy/mapfiles/630c2909dfxxx.10265915.txt)] if acl_630c2xxx7624.21524463 # ACTION: PUBLIC_SUBDOMAINS_map-rule # NOTE: actions with no ACLs/conditions will always match use_backend %[req.hdr(host),lower,map_dom(/tmp/haproxy/mapfiles/630c262xxx9c50.82551607.txt)] # Backend: SSL_backend ()backend SSL_backend # health checking is DISABLED mode tcp balance source # stickiness stick-table type ip size 50k expire 30m stick on src server SSL_server 127.4.4.3 send-proxy-v2 check-send-proxy# Backend: opnsense_backend ()backend opnsense_backend # health checking is DISABLED mode http balance source # stickiness stick-table type ip size 50k expire 30m stick on src http-reuse safe server opnsense_server 20.14.0.1:55443 ssl verify none# Backend: truenas_backend ()backend truenas_backend # health checking is DISABLED mode http balance source # stickiness stick-table type ip size 50k expire 30m stick on src http-reuse safe server truenas_server 20.xxx.4 ssl verify none# Backend: proxmox_backend ()backend proxmox_backend # health checking is DISABLED mode http balance source # stickiness stick-table type ip size 50k expire 30m stick on src http-reuse safe server proxmox_server 20.xxx47:8xxx6 ssl verify none# Backend: ad_backend ()backend ad_backend # health checking is DISABLED mode http balance source # stickiness stick-table type ip size 50k expire 30m stick on src http-reuse safe server ad_server 20.xxx.1:56xxx43 ssl verify none# Backend (DISABLED): proxmox_backend_1 ()# Backend (DISABLED): truenas_backend_1 ()# statistics are DISABLEDOPNsense (c) 2014-2023 Deciso B.V.As for my domain for the certificate I followed your guide and have it at Common name *.xxxan.toAs for the DNS Zone I'm using your guide https://desec.ioCNAME is *.mydomainname.toI don't have A record (I didn't see it in your guide)I checked and my dyanmic DNS server still update my IP address to desec. Also when I tried to restart my authentication service, I see my token on desec being rewnewed. So I think that aspect it work.I can access my domain if i have that server running i.e. adguard, plex. However, if I just type in my domain name it doesn't resolve my public ip anymore. I think it at desec end but I've tried to add and delete my domain but nothing seemed to work.
OK, I gave it a shot. Not sure if my http config is correct. Servers seem to be working except for the one that needs http, I am currently checking it out.But here is my config. Code: [Select]## Automatically generated configuration.# Do not edit this file manually.#global uid 80 gid 80 chroot /var/haproxy daemon stats socket /var/run/haproxy.socket group proxy mode 775 level admin nbthread 4 hard-stop-after 60s no strict-limits maxconn 10000 tune.ssl.default-dh-param 4096 spread-checks 2 tune.bufsize 16384 tune.lua.maxmem 0 log 0.0.0.0 local0 info lua-prepend-path /tmp/haproxy/lua/?.luadefaults log global option redispatch -1 maxconn 5000 timeout client 30s timeout connect 30s timeout server 30s retries 3 default-server init-addr last,libc default-server maxconn 5000# autogenerated entries for ACLs# autogenerated entries for config in backends/frontends# autogenerated entries for stats# Frontend: SNI_frontend ()frontend SNI_frontend bind 0.0.0.0:443 name 0.0.0.0:443 mode tcp # logging options option tcplog # ACL: TCP_SSL_condition acl acl_644c56b6785678.47181279 req.ssl_hello_type 1 # ACL: NoSSL_condition acl acl_644d62959d73a1.59974462 ssl_fc # ACL: server1_condition acl acl_644c5700ee7657.09485748 req.ssl_sni -m sub -i domain1.com # ACL: server2_condition acl acl_644c5719768e71.87060950 req.ssl_sni -i domain2.com # ACTION: TCP_RequestInspectDelay_rule # NOTE: actions with no ACLs/conditions will always match tcp-request inspect-delay 5s # ACTION: TCP_RequestContentAccept_rule tcp-request content accept if acl_644c56b6785678.47181279 # ACTION: server1_rule use_backend server1_backend if !acl_644d62959d73a1.59974462 acl_644c5700ee7657.09485748 # ACTION: server2_rule use_backend server2_backend if !acl_644d62959d73a1.59974462 acl_644c5719768e71.87060950# Frontend: HTTP_frontend ()frontend HTTP_frontend bind 0.0.0.0:80 name 0.0.0.0:80 mode tcp # logging options option tcplog # ACL: NoSSL_condition acl acl_644d62959d73a1.59974462 ssl_fc # ACL: server2_condition acl acl_644c5719768e71.87060950 req.ssl_sni -i domain2.com # ACL: server1_condition acl acl_644c5700ee7657.09485748 req.ssl_sni -m sub -i domain1.com acl acl_644c56b6785678.47181279 req.ssl_hello_type 1 # ACTION: server2_rule use_backend server2_backend if !acl_644d62959d73a1.59974462 acl_644c5719768e71.87060950 # ACTION: server1_rule use_backend server1_backend if !acl_644d62959d73a1.59974462 acl_644c5700ee7657.09485748 # ACTION: TCP_RequestInspectDelay_rule # NOTE: actions with no ACLs/conditions will always match tcp-request inspect-delay 5s # ACTION: TCP_RequestContentAccept_rule tcp-request content accept if acl_644c56b6785678.47181279# Backend: server1_backend ()backend server1_backend # health checking is DISABLED mode tcp balance source # stickiness stick-table type ip size 50k expire 30m stick on src server server1_server 192.168.1.234 # Backend: server2_backend ()backend server2_backend # health checking is DISABLED mode tcp balance source # stickiness stick-table type ip size 50k expire 30m stick on src server server2_server 192.168.1.231 # statistics are DISABLED
Hello,I read your suggestion and just blindly tried to add the A Record in my desec, with my public IP address and voila, I were able to access my public IP. May I ask what happened or changed? I apologize if my question is not very smart. If I add my A record like this, will I be able to have my IP address automatically update? I know with your guide, through the token management, It receive IP update from my Opnsense dynamicDNS. However, if my record is using A Record, I have to manually enter the IP in myself.THank you so much for your time.