Skip to content

Commit 004b36e

Browse files
committed
new-ip-based-tls-tutorial
1 parent eb6257b commit 004b36e

20 files changed

+273
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2024 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
# Setting up a free TLS certificate for testing HTTPS connections on OCI Load Balancer
2+
3+
Owner: Paul Toal
4+
5+
Within OCI, the [Load Balancer Service](https://docs.oracle.com/en-us/iaas/Content/Balance/Concepts/balanceoverview.htm) enables you to create resilient connections to backend resources such as web servers.
6+
7+
Sometimes when you are testing backend services it is necessary to use a HTTPS connection. Normally, TLS certificates are issued against fully qualified domain names. However, it isn't always possible or quick and easy to register your testing resources with a domain.
8+
9+
In this tutorial, I will walk you through the process of quickly enabling HTTPS connection through the OCI load balancer, using a free TLS certificate generated by [ZeroSSL](https://app.zerossl.com/dashboard), and generated against an IP address.
10+
11+
## Prerequisites
12+
13+
- An OCI tenancy.
14+
- An OCI Administrator with appropriate permissions to create and manage load balancers and associated resources.
15+
- Created a sample web site deployed on OCI.
16+
17+
> **Note** For this tutorial, I have created a compute instance called **apache** and installed and configured the Apache HTTPD service on it, running on port 80.
18+
19+
# Create the Load Balancer
20+
21+
Initially, we will create the load balancer and configure the HTTP listener on port 80. This will enable us to obtain the public IP address of the load balancer, which we will need to create the IP address-based TLS certificate.
22+
23+
> **Note** If you are planning on using a reserved IP address and already know the public IP address, you can skip the creation of the HTTP listener and configure the HTTPS listener from the start.
24+
25+
1. Login to your OCI console and navigate to **Networking**, then **Load Balancer** from the **Load Balancers** menu.
26+
27+
2. Select the appropriate compartment and click `Create Load Balancer`.
28+
29+
3. In the **Add details** screen, provide the following information:
30+
31+
- Load balancer name: `lb-for-apache`
32+
33+
Leave the following values as their defaults:
34+
35+
- Choose visibility type: `Public`
36+
- Assign a public IP address: `Ephemeral IP address`
37+
- Choose the minimum bandwidth: `10`
38+
- Choose the maximum bandwidth: `10`
39+
- Choose networking
40+
-> VCN: Choose your VCN
41+
-> Subnet: Choose your public subnet
42+
43+
4. Leave all other values as default and click `Next'.
44+
45+
5. On the **Choose backends** screen, click `Add backends`.
46+
47+
6. Select the checkbox next to your compute instance (in my case `apache`) from the list of instances.
48+
49+
![Screenshot for selecting the backend.](lb-select-backend.png "Screenshot for selecting the backend.")
50+
51+
7. Click `Add selected backends`.
52+
53+
8. Leave the port for your backend as port 80.
54+
55+
9. Leave the health check policy as default.
56+
57+
10. Click `Next`.
58+
59+
11. On the **Configure listener** screen, provide the following information:
60+
61+
- Name: `listener-http`
62+
- Specify the type of traffic your listener handles: `HTTP`
63+
- Specify the port your listener monitors for ingress traffic: `80`
64+
65+
12. Click `Next`.
66+
67+
13. Since, this is a test, disable **Error logs** and **Access Logs** (if enabled).
68+
69+
![Screenshot for load balancer logging.](lb-logging.png "Screenshot for load balancer logging.")
70+
71+
14. Click `Submit`.
72+
73+
Your load balancer will be created after a few moments.
74+
75+
![Screenshot for load balancer summary.](lb-created.png "Screenshot for load balancer summary.")
76+
77+
> **Note** If you have enabled the network traffic to your HTTPD server, and if it is running, **Backend sets health** shoudl be showing as **OK**. If not, check your networking and security lists.
78+
79+
15. Make a note of the public IP address of your load balancer.
80+
81+
# Test the Load Balancer
82+
83+
Before we enable a HTTPS connection to the web server, let's check out load balancer is working and routing traffic correctly.
84+
85+
1. Open a browser and navigate to `http://<your LB public IP address>/`, accepting the HTTP warning issued by your browser.
86+
87+
![Screenshot for HTTP web site access.](browser-http.png "Screenshot for HTTP web site access.")
88+
89+
# Generate the TLS certificate
90+
91+
Now that we have our load balancer listening on HTTP with a public IP address, we can generate an IP-based TLS certificate.
92+
93+
For this tutorial, i'm using [ZeroSSL](https://app.zerossl.com/dashboard), primarily because they offer the ability to generate up to three, 90-day certificates for free, and will generate certificates based on IP addresses, not just domain names.
94+
95+
1. Navigate to `https://app.zerossl.com/dashboard`.
96+
97+
2. If you don't already have one, register for a free account and login.
98+
99+
3. Click on `New Certificate` to start the certificate generation wizard.
100+
101+
4. Enter the IP address of your load balancer in the **Domain Name** field.
102+
103+
The IP will be validated as shown by the green tick.
104+
105+
![Screenshot for entering IP on ZeroSSL new certificate screen.](zerossl-ip.png "Screenshot for entering IP on ZeroSSL new certificate screen.")
106+
107+
5. Click **Next Step ->**
108+
109+
4. Under **Validity**, select `90-Day Certificate`.
110+
111+
![Screenshot for entering validity on ZeroSSL new certificate screen.](zerossl-validity.png "Screenshot for entering validity on ZeroSSL new certificate screen.")
112+
113+
5. Click **Next Step ->**
114+
115+
6. Don't select any add-ons.
116+
117+
![Screenshot for entering add-ons on ZeroSSL new certificate screen.](zerossl-addons.png "Screenshot for entering add-ons on ZeroSSL new certificate screen.")
118+
119+
7. Click **Next Step ->**
120+
121+
8. On the **CSR & Contact** screen, ensure `Auto-Generate CSR` is enabled.
122+
123+
![Screenshot for entering CSR on ZeroSSL new certificate screen.](zerossl-CSR.png "Screenshot for entering CSR on ZeroSSL new certificate screen.")
124+
125+
9. Click **Next Step ->**
126+
127+
10. Under **Finalize Your Order**, leave `Free` selected.
128+
129+
![Screenshot for entering order on ZeroSSL new certificate screen.](zerossl-freeorder.png "Screenshot for entering order on ZeroSSL new certificate screen.")
130+
131+
11. Click **Next Step ->**
132+
133+
Before ZeroSSL will issue a certificate, you must verify that you control the IP address that you have requested a certificate for. Since this is a free, 90-day certificate, the only method of validation is to upload a temporary file to your web server.
134+
135+
12. Follow the instructions to upload the pki-validation file to your web server into the folder specified by ZeroSSL.
136+
137+
![Screenshot for verifying IP address.](zerossl-verify.png "Screenshot for verifying IP address.")
138+
139+
13. Once the file is in place, click **Verify Domain** to start the verification process.
140+
141+
After successful verification, your certificate will be generated.
142+
143+
14. Click **Download Certificate (.zip)** to obtain the necessary certificate and key files from ZeroSSL.
144+
145+
![Screenshot for ZerosSSL certificate download.](zerossl-download.png "Screenshot for ZerosSSL certificate download.")
146+
147+
15. Extract the zip file to a suitable folder on your local machine. It contains three files:
148+
149+
- **certificate.crt** - is the actual X.509 certificate
150+
- **ca_bundle.crt** - is the signing certificate
151+
- **private.key** - is the private key for your certificate
152+
153+
We will need all three in the next step.
154+
155+
# Create the HTTPS listener
156+
157+
Now that we have our 90-day TLS certificate from ZeroSSL, we can create a HTTPS listener on our load balancer.
158+
159+
1. Back in the OCI console, navigate back to your load balancer at **Networking**, then **Load Balancer** from the **Load Balancers** menu.
160+
161+
2. Select your **lb-for-apache** load balancer.
162+
163+
Before creating the HTTPS listener, we need to import our new certificate.
164+
165+
3. From the **Resources** left-hand menu, select **Certificates**.
166+
167+
4. Change the **Certificate Resources** to `Load balancer managed certificate`.
168+
169+
![Screenshot for certificate selection.](lb-cert-list.png "Screenshot for certificate selection.")
170+
171+
5. Click **Add certificate**.
172+
173+
6. Provide a name for your certificate such as its IP address.
174+
175+
![Screenshot for certificate name.](cert-name.png "Screenshot for certificate name.")
176+
177+
7. Under **Choose SSL certificate file**, drop your `certificate.crt` file into the box.
178+
179+
![Screenshot for certificate file.](cert-cert.png "Screenshot for certificate file.")
180+
181+
8. Check the **Specify CA certificate** check box.
182+
183+
9. Under **Choose CA certificate file**, drop your `ca_bundle.crt` file into the box.
184+
185+
![Screenshot for CA certificate file.](cert-ca.png "Screenshot for certificate file.")
186+
187+
8. Check the **Specify private key** check box.
188+
189+
9. Under **Choose CA private key file**, drop your `private.key` file into the box.
190+
191+
![Screenshot for private key file.](cert-priv.png "Screenshot for private key file.")
192+
193+
10. Click **Add certificate** to to finalise the addition of the certificate.
194+
195+
11. Click **Close** on the **Work Request** and wait for the new certificat to appear in the list of certificates (a new moments).
196+
197+
![Screenshot for imported cert.](cert-list.png "Screenshot for imported cert.")
198+
199+
Now that we have our certificate imported, we can create the new listener.
200+
201+
12. From the **Resources** left-hand menu, select **Listeners**.
202+
203+
13. Click **Create listener**.
204+
205+
14. Provide following values on the **Create listener screen:
206+
207+
- Name: `listener-https`
208+
- Protocol: `HTTPS`
209+
- Port: `443`
210+
- Use SSL: Checked
211+
- SSL certificate
212+
- Certificate resource: `Load balancer managed certificate`
213+
- Certificate name: `<your LB public IP address>` (or the name you specified in step 6 above)
214+
- Backend set: Select your backend set from the dropdown list
215+
216+
15. Click **Create listener**.
217+
218+
16. Click **Close** on the **Work request submitted** screen and wait for the new listener to appear.
219+
220+
# Testing our new listener
221+
222+
Now that we have created the HTTPS listener, we can test it.
223+
224+
1. Open a browser and navigate to `https://<your LB public IP address>/`.
225+
226+
You will see that you now have a secure connection to your web server, as indicated by the padlock in your browser address bar.
227+
228+
![Secure browser connection to web site.](browser-https.png "Secure browser connection to web site.")
229+
230+
This completes the lab.
231+
232+
# License
233+
234+
Copyright (c) 2024 Oracle and/or its affiliates.
235+
236+
Licensed under the Universal Permissive License (UPL), Version 1.0.
237+
238+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.
19.1 KB
Loading
18.2 KB
Loading
73.4 KB
Loading
59.5 KB
Loading
105 KB
Loading
95.9 KB
Loading
61.1 KB
Loading
138 KB
Loading

0 commit comments

Comments
 (0)