Skip to content

Add HTTPS to the test.opendap.org server. #6

@jgallagher59701

Description

@jgallagher59701

Here's what Google's AI has to say about this, given that I asked it:

I have an EC2 instance running ubuntu that already has a domain name pointing to the instance's IP address. I am running an Apache httpd server there. This is a single instance web server, so I don't want the extra cost of an AWS ALB. How do I set up HTPPS for this web server?

The answer is below (see 'Answer:') but, we need to think about the whole architecture, which might not work as easily as simple htttpd HTTPS support.

Generic components Custom components
apache --> ajp --> tomcat --> | --> olfs --> bes

The certbot approach, which seems reasonable, will work with ajp, but there could be issues if any of the code inside apache/ajp uses HTTP (and not HTTPS). That is, if any of the code makes absolute UTLs. There can also be issues with cookies that use secure, redirects, maybe other stuff.

My vote is that we do this, but we need a bit more thought than just the vanilla certbot install.

Answer:
To set up HTTPS on your single EC2 Ubuntu instance without an AWS Application Load Balancer (ALB), you can use [Certbot](https://certbot.eff.org/) to obtain a free SSL/TLS certificate from [Let's Encrypt](https://letsencrypt.org/docs/). This tool automates the issuance and installation of the certificate directly onto your Apache server. [1, 2, 3, 4]

1. Update EC2 Security Group

Before running commands, ensure your EC2 instance can receive HTTPS traffic: [5, 6]

  • Go to the [Amazon EC2 Console](https://console.aws.amazon.com/ec2/).
  • Navigate to Security Groups and select the one attached to your instance.
  • Add an Inbound Rule for HTTPS (Port 443) from source 0.0.0.0/0.
  • Ensure HTTP (Port 80) is also open, as Certbot needs it to verify domain ownership. [5, 7, 8, 9]

2. Install Certbot

Use the standard Ubuntu package manager or snap (the recommended method) to install Certbot and its Apache plugin. [10, 11]

Update local package index

sudo apt update

Install Certbot and the Apache plugin

sudo apt install certbot python3-certbot-apache

Note: If you prefer the [official Snap-based installation](https://certbot.eff.org/instructions?ws=other&os=ubuntufocal) for the most up-to-date version, use sudo snap install --classic certbot instead. [10, 11]

3. Obtain and Install the Certificate

Run Certbot with the --apache flag. This script automatically finds your domain in your Apache configuration and sets up the SSL virtual host. [3, 12, 13]

sudo certbot --apache -d yourdomain.com -d ://yourdomain.com

During the process:

  • Enter a valid email address for renewal notices.
  • Agree to the Terms of Service.
  • Choose whether to Redirect all HTTP traffic to HTTPS (highly recommended). [3, 4, 14]

4. Verify Auto-Renewal [3]

Let's Encrypt certificates are valid for 90 days, but Certbot automatically adds a timer or cron job to handle renewals. Test this process with a "dry run": [15, 16, 17, 18, 19]

sudo certbot renew --dry-run

If you see "Congratulations, all simulated renewals succeeded," your server will automatically renew its own certificate before it expires. [17, 20, 21]

NB: If the Certbot can't find your domain automatically, the Apache virtual host file might have to be hacked

[1] [https://repost.aws](https://repost.aws/articles/ARLx7JGFgmTdieKLIWtKiuaw/use-certbot-to-enable-https-on-ubuntu-linux-ec2-instances-running-apache-or-nginx)
[2] [https://www.reddit.com](https://www.reddit.com/r/aws/comments/1ewgndk/how_do_i_point_a_domain_name_at_an_ec2_instance/)
[3] [https://www.linuxbabe.com](https://www.linuxbabe.com/ubuntu/https-apache-letsencrypt-ubuntu)
[4] [https://upcloud.com](https://upcloud.com/resources/tutorials/install-lets-encrypt-apache/)
[5] [https://stackoverflow.com](https://stackoverflow.com/questions/5309910/https-setup-in-amazon-ec2-instance)
[6] [https://businesscompassllc.com](https://businesscompassllc.com/connecting-your-domain-on-cloudflare-to-your-aws-ec2-instance-a-step-by-step-guide/#:~:text=Other%20Common%20Issues%20Verify%20that%20your%20EC2,Ensure%20your%20security%20groups%20allow%20HTTP/HTTPS%20traffic.)
[7] [https://certbot.eff.org](https://certbot.eff.org/instructions?ws=other&os=ubuntufocal)
[8] [https://repost.aws](https://repost.aws/knowledge-center/connect-http-https-ec2)
[9] [https://www.javahabit.com](https://www.javahabit.com/2013/10/24/launch-website-in-amazon-ec2/#:~:text=Go%20to%20your%20Console%20and%20select%20EC2%20%28%20Amazon%20EC2%20%29%20tab.)
[10] [https://certbot.eff.org](https://certbot.eff.org/instructions?ws=apache&os=snap)
[11] [https://www.linode.com](https://www.linode.com/docs/guides/enabling-https-using-certbot-with-apache-on-ubuntu/)
[12] [https://www.digitalocean.com](https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04)
[13] [https://saitejairrinki.medium.com](https://saitejairrinki.medium.com/setting-up-a-website-on-aws-ec2-with-apache-server-and-installing-ssl-certificate-using-lets-39dc6a69641e#:~:text=The%20%60%20%E2%80%94%20apache%60%20flag%20tells%20Certbot%20to%20use%20the%20Apache%20plugin%20for%20installation.)
[14] [https://www.youtube.com](https://www.youtube.com/watch?v=T0XZGA-Q-K4&t=7)
[15] [https://www.digitalocean.com](https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu)
[16] [https://www.youtube.com](https://www.youtube.com/watch?v=hQTQGWTVliM)
[17] [https://www.youtube.com](https://www.youtube.com/watch?v=bOA2_Wd_GIY)
[18] [https://www.cherryservers.com](https://www.cherryservers.com/blog/host-a-website-on-linux-vps#:~:text=Let%27s%20Encrypt%20certificates%20are%20valid%20for%2090,them.%20Set%20up%20auto%2Drenewal%20with%20this%20command.)
[19] [https://habil.medium.com](https://habil.medium.com/setting-up-ssl-on-aws-elastic-beanstalk-single-instances-53e97ec5c3db#:~:text=How%20This%20Solution%20Works%20The%20configuration%20installs,to%20automatically%20renew%20the%20certificate%20before%20expiration)
[20] [https://isaacdarcilla.com](https://isaacdarcilla.com/blog/install-and-configure-apache-with-ssl-on-an-ec2-ubuntu-instance-for-free-with-certbot)
[21] [https://www.cantech.in](https://www.cantech.in/knowledge-base/how-to-install-apache-web-server-on-ubuntu-24-04/)

Metadata

Metadata

Labels

enhancementNew feature or request
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions