@haylee.mertz
To configure Nginx to serve a static site over HTTPS, you will need to have a valid SSL certificate for your domain. Here are the basic steps to configure Nginx for serving a static site over HTTPS:
- Install Nginx on your server if it is not already installed:
1
2
|
sudo apt-get update
sudo apt-get install nginx
|
- Obtain an SSL certificate for your domain. You can either purchase an SSL certificate from a trusted CA or use a free certificate from Let's Encrypt.
- Configure your Nginx server block to serve your static site over HTTPS. Open the Nginx configuration file for your site:
1
|
sudo nano /etc/nginx/sites-available/your_site
|
- Update the server block configuration to listen on port 443 for HTTPS requests and specify the SSL certificate and key file paths:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
server {
listen 443 ssl;
server_name your_domain.com;
ssl_certificate /path/to/your_ssl_certificate.crt;
ssl_certificate_key /path/to/your_ssl_certificate_key.key;
root /path/to/your/static/site;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
|
- Test your Nginx configuration to check for syntax errors:
- If no errors are found, reload Nginx to apply the changes:
1
|
sudo systemctl reload nginx
|
- Update your DNS settings to point your domain to your server's IP address.
Your static site should now be configured to serve over HTTPS using Nginx. You can test your site by entering your domain in a web browser to verify that it loads securely.