-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdefault.conf
99 lines (76 loc) · 3.21 KB
/
default.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# this file is located in /etc/nginx/conf.d/ directory
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name YourDNSServer;
root /var/www/html;
autoindex off;
index pihole/index.php index.php index.html index.htm;
location / {
expires max;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.4-fpm.sock; # Ensure you use the correct PHP-FPM version here
fastcgi_param FQDN true;
}
location /*.js {
index pihole/index.js;
}
location /admin {
root /var/www/html;
index index.php index.html index.htm;
}
location ~ /\.ht {
deny all;
}
# turn on the HTTP-to-HTTPS 302 redirect
if ($host = YourDNSServerIPaddress) {
return 302 http://YourDNSServer$request_uri;
}
return 302 https://YourDNSServer$request_uri;
}
#########################################
# now let's do the same same for port 443
server {
# note the http2 verb added here
listen [::]:443 http2 ssl ipv6only=on; # Note that we enable H2 support, because why not
listen 443 ssl http2 default_server;
server_name YourDNSServer;
# I always like using the FQDN instead of an IP address
if ($host = YourDNSServerIPaddress) {
return 302 https://YourDNSServer$request_uri;
}
# Here comes our Let's Encrypt TLS certificate. These lines were automagically added by Let's Encrypt CERTBOT
ssl_certificate /etc/letsencrypt/live/YourDNSServer/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/YourDNSServer/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# enable TLSv1.2. I am seeing it negotiating TLS 1.3 when accessing PiHole's UI via the browser
ssl_protocols TLSv1.2;
root /var/www/html;
autoindex off;
index pihole/index.php index.php index.html index.htm;
location / {
expires max;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.4-fpm.sock; # again, ensure you have the correct PHP-FPM version
fastcgi_param FQDN true;
}
location /*.js {
index pihole/index.js;
}
location /admin {
root /var/www/html;
index index.php index.html index.htm;
}
location ~ /\.ht {
deny all;
}
}