-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx_base_conf
37 lines (31 loc) · 1.49 KB
/
nginx_base_conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## ATTENZZIONEEEEE ##
#
# You should look at the following URLs in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
##
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
server_name <your-domain>; # Replace with your domain or subdomain (e.g., example.com)
# Redirect all HTTP traffic to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl; # Use SSL for secure connections
server_name <your-domain>; # Replace with your domain or subdomain (e.g., example.com)
# Set the root directory for the website
root /var/www/html; # Path to your website files, adjust as needed
index index.html index.htm index.nginx-debian.html; # Default index files
location / {
try_files $uri $uri/ =404; # Return 404 if the file is not found
}
# SSL certificate paths (managed by Certbot)
ssl_certificate /etc/letsencrypt/live/<your-domain>/fullchain.pem; # Replace <your-domain> with your actual domain
ssl_certificate_key /etc/letsencrypt/live/<your-domain>/privkey.pem; # Replace <your-domain> with your actual domain
include /etc/letsencrypt/options-ssl-nginx.conf; # SSL configuration managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # Diffie-Hellman parameters for SSL security
}