{"id":601,"date":"2019-04-02T22:22:35","date_gmt":"2019-04-03T03:22:35","guid":{"rendered":"http:\/\/zewwy.ca\/?p=601"},"modified":"2019-04-02T22:22:52","modified_gmt":"2019-04-03T03:22:52","slug":"zewwy-has-not-one-but-two-epiphanies","status":"publish","type":"post","link":"https:\/\/zewwy.ca\/index.php\/2019\/04\/02\/zewwy-has-not-one-but-two-epiphanies\/","title":{"rendered":"Zewwy has not one but two Epiphanies"},"content":{"rendered":"<h1 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"The_Story\"><\/span><strong>The Story<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>Nothing goes better together than a couple moments of realization, and fine blog story. It was a fine brisk morning, on the shallow tides of the Canadian West&#8230; as the sun light gazed upon his glorious cheek&#8230; wait wait wait&#8230; wrong story telling.<\/p>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"The_First_Epiphany\"><\/span>The First Epiphany<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>First to get some reference see my <a href=\"http:\/\/zewwy.ca\/index.php\/2019\/02\/24\/opnsense-for-exchange-reverse-proxy\/\">blog post here<\/a> on setting up OPNsense as a reverse proxy, in this case I had no authentication and my backend pool was a single server so nothing oo-lala going on here. I did however re-design my network to encompass my old dynamic IP for my static one. One itsy bitsy problem I&#8217;m restricted on physical adapters, which isn&#8217;t a big deal, with trunking and VLAN tagging and all that stuff&#8230; however, I am limited on public IP addresses, and the amount of ports that can listen on the standard ports&#8230; which is well one for one&#8230; If it wasn&#8217;t for security, host headers would solve this issue with ease at the application layer (the web server or load balancer) with the requirement of HTTPS there&#8217;s just one more hurdle to overcome&#8230; but with the introduction of TLS 1.2 (over ten years now, man time flys) we can use Server Name Indication (SNI) to provide individual certs for each host header being served. Mhmmm yeah.<\/p>\n<p>This of course is not the epiphany&#8230; no no, it was simply how to get HAproxy plugin on OPNsense configured to use SNI. All the research I did, which wasn&#8217;t too much just some quick Googling&#8230; revealed that most configurations were manual via a conf file. Not that I have anything against that *cough Human error due to specialized syntax requirements*&#8230; it&#8217;s just that UIs are sort of good for these sort of things&#8230;.<\/p>\n<p>The light bulb on what to do didn&#8217;t click (my epiphany) till I read <a href=\"https:\/\/stuff-things.net\/2016\/11\/30\/haproxy-sni\/\">this blog post<\/a>&#8230; from stuff-things.net &#8230; how original haha<\/p>\n<p>It was this line when the light-bulb went off&#8230;<\/p>\n<p>&#8220;All you need to do to enable SNI is to be give HAProxy multiple SSL certificates&#8221; also note the following he states&#8230; &#8220;In pass-through mode SSL, HAProxy doesn\u2019t have a certificate because it\u2019s not going to decrypt the traffic and that means it\u2019s never going to see the Host header. Instead it needs to be told to wait for the SSL hello so it can sniff the SNI request and switch on that&#8221; this is a lil hint of the SSL inspection can of worms I&#8217;ll be touching on later. Also I was not able to specifically figure out how to configure pass-though SSL using SNI&#8230; Might be another post however at this time I don&#8217;t have a need for that type of configuration.<\/p>\n<p>Sure enough, since I had multiple Certificates already created via the Let&#8217;s encrypt plugin&#8230; All I had to do was specify multiple certificates&#8230; then based on my &#8220;Rules\/Actions\/Conditions&#8221; (I used host based rules to trigger different backend pools) zewwy.ca -&gt; WordPress and owa.zewwy.ca -&gt; exchange server<\/p>\n<p><a href=\"https:\/\/i.imgur.com\/BXj6l7w.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/BXj6l7w.png\" alt=\"\" width=\"567\" height=\"619\" \/><\/a><\/p>\n<p>and just like that I was getting proper certificates for each service, using unique certs&#8230; on OPNsense 19.1 and HAProxy Plugin, with alternative back-end services&#8230; now that&#8217;s some oo-lala.<\/p>\n<p>My happiness was sort lived when a new issue presented it&#8217;self when I went to check my site via HTTPS:<\/p>\n<p><a href=\"https:\/\/i.imgur.com\/P0Hm0Gf.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/P0Hm0Gf.png\" alt=\"\" width=\"1012\" height=\"722\" \/><\/a><\/p>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"The_Second_Epiphany\"><\/span>The Second Epiphany<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>I let this go the first night as I accepted my SNI results as a victory. Even the next day this issue was already starting to bother me&#8230; and I wanted to know what the root of the issue was.<\/p>\n<p>At first I started looking at the Chrome debug console&#8230; notice it complaining about some of the plugins I was using and that they were seem as unsafe<\/p>\n<p><a href=\"https:\/\/i.imgur.com\/1Bpegyk.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/1Bpegyk.png\" alt=\"\" width=\"997\" height=\"705\" \/><\/a><\/p>\n<p>but the point is it was not the droids I was actually after&#8230; but it was the line (blocked:mixed-content) that set off the light bulb&#8230;<\/p>\n<p>So since I was doing SNI on the SSL listener, but I I was specifying my &#8220;Rule\/Action&#8221; that was pointing to my Backend Server that was using the normal HTTP real server. I however wanted to keep regular HTTP access open to my site not just for a HTTP-&gt;HTTPS redirect. I had however another listener available for exactly just that. At this point it was all just assumptions, even though from some post I read you can have a HTTPS load balancer hosting a web page over HTTPS while the back-end server is just HTTP. So Not sure on that one, but I figured I&#8217;d give it a shot.<\/p>\n<p>So first I went back to <a href=\"http:\/\/zewwy.ca\/index.php\/2018\/11\/19\/secure-a-wordpress-site-with-https\/\">my old blog post on getting HTTPS setup on my WordPress website<\/a> but without the load balancer&#8230; turns out it was still working just fine!<\/p>\n<p>Then I simply created a new physical server in HAProxy plugin,<\/p>\n<p><a href=\"https:\/\/i.imgur.com\/4XNqT7x.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/4XNqT7x.png\" alt=\"\" width=\"627\" height=\"530\" \/><\/a><\/p>\n<p>created a new back-end Pool for my secure WordPress connection<\/p>\n<p><a href=\"https:\/\/i.imgur.com\/rSlEDVA.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/rSlEDVA.png\" alt=\"\" width=\"649\" height=\"571\" \/><\/a><\/p>\n<p>created a new &#8220;Rule\/Action&#8221; using my existing host header based condition<\/p>\n<p><a href=\"https:\/\/i.imgur.com\/1Xh3ad0.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/1Xh3ad0.png\" alt=\"\" width=\"647\" height=\"585\" \/><\/a><\/p>\n<p>and applied it to my listener instead of the standard HTTP rule (Rules on the SSL listener shown in the first snippet):<\/p>\n<p><a href=\"https:\/\/i.imgur.com\/iZW8jUJ.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/iZW8jUJ.png\" alt=\"\" width=\"622\" height=\"158\" \/><\/a><\/p>\n<p>Now when we access our site via HTTPS this time&#8230;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/ciqEizq.png\" \/><\/p>\n<p>Clean baby clean! Next up some IDS rules and inspection to prevent brute force attempts, SQL injections&#8230; Cross site scripting.. yada yada, all the other dirty stuff hackers do. Also those 6 cookies, where did those come from? Maybe I&#8217;ll also be a cookie monster next post&#8230; who knows!<\/p>\n<p>I hope you enjoyed my stories of &#8220;ah-ha moments&#8221;. Please share your stories in the comments. \ud83d\ude00<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Story Nothing goes better together than a couple moments of realization, and fine blog story. It was a fine brisk morning, on the shallow tides of the Canadian West&#8230; as the sun light gazed upon his glorious cheek&#8230; wait wait wait&#8230; wrong story telling. The First Epiphany First to get some reference see my &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/zewwy.ca\/index.php\/2019\/04\/02\/zewwy-has-not-one-but-two-epiphanies\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Zewwy has not one but two Epiphanies&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","footnotes":""},"categories":[4,6,8],"tags":[164,186,56],"class_list":["post-601","post","type-post","status-publish","format-standard","hentry","category-infosec","category-networking","category-server-administration","tag-opnsense","tag-sni","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/posts\/601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/comments?post=601"}],"version-history":[{"count":1,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/posts\/601\/revisions"}],"predecessor-version":[{"id":602,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/posts\/601\/revisions\/602"}],"wp:attachment":[{"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/media?parent=601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/categories?post=601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/tags?post=601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}