Skip to content

Commit 3f692c2

Browse files
committed
Update MS installs to include HTTPS be default
1 parent 5779b81 commit 3f692c2

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
This repository contains the Nginx configurations used within the series [Hosting WordPress Yourself](https://deliciousbrains.com/hosting-wordpress-setup-secure-virtual-server/). It contains best practices from various sources, including the [WordPress Codex](https://codex.wordpress.org/Nginx) and [H5BP](https://github.com/h5bp/server-configs-nginx). The following example sites are included:
44

55
* fastcgi-cache.com - WordPress with [FastCGI caching](https://deliciousbrains.com/hosting-wordpress-yourself-server-monitoring-caching/#page-cache)
6-
* multisite-subdomain.com - WordPress Multisite install using subdomains
7-
* multisite-subdirectory.com - WordPress Multisite install using subdirectories
6+
* multisite-subdirectory.com - WordPress multisite install using subdirectories
7+
* multisite-subdomain.com - WordPress multisite install using subdomains
88
* single-site.com - WordPress single site install
99
* single-site-with-caching.com - WordPress single site install with FastCGI caching
1010
* single-site-no-ssl.com - WordPress single site install (no SSL or page caching)

sites-available/multisite-subdirectory.com

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
server {
22
# Ports to listen on
3-
listen 80;
4-
listen [::]:80;
3+
listen 443 ssl http2;
4+
listen [::]:443 ssl http2;
55

66
# Server name to listen for
77
server_name multisite-subdirectory.com;
88

99
# Path to document root
1010
root /sites/multisite-subdirectory.com/public;
1111

12+
# Paths to certificate files.
13+
ssl_certificate /etc/letsencrypt/live/multisite-subdirectory.com/fullchain.pem;
14+
ssl_certificate_key /etc/letsencrypt/live/multisite-subdirectory.com/privkey.pem;
15+
1216
# File to be used as index
1317
index index.php;
1418

@@ -22,6 +26,9 @@ server {
2226
# Multisite subdirectory install
2327
include global/server/multisite-subdirectory.conf;
2428

29+
# SSL rules
30+
include global/server/ssl.conf;
31+
2532
location / {
2633
try_files $uri $uri/ /index.php?$args;
2734
}
@@ -36,6 +43,16 @@ server {
3643
}
3744
}
3845

46+
# Redirect http to https
47+
server {
48+
listen 80;
49+
listen [::]:80;
50+
server_name multisite-subdirectory.com;
51+
52+
return 301 https://$host$request_uri;
53+
}
54+
55+
3956
# Redirect www to non-www
4057
server {
4158
listen 80;

sites-available/multisite-subdomain.com

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
server {
22
# Ports to listen on
3-
listen 80;
4-
listen [::]:80;
3+
listen 443 ssl http2;
4+
listen [::]:443 ssl http2;
55

66
# Server name to listen for
77
server_name multisite-subdomain.com *.multisite-subdomain.com;
88

99
# Path to document root
1010
root /sites/multisite-subdomain.com/public;
1111

12+
# Paths to certificate files.
13+
ssl_certificate /etc/letsencrypt/live/multisite-subdomain.com/fullchain.pem;
14+
ssl_certificate_key /etc/letsencrypt/live/multisite-subdomain.com/privkey.pem;
15+
1216
# File to be used as index
1317
index index.php;
1418

@@ -19,6 +23,9 @@ server {
1923
# Default server block rules
2024
include global/server/defaults.conf;
2125

26+
# SSL rules
27+
include global/server/ssl.conf;
28+
2229
location / {
2330
try_files $uri $uri/ /index.php?$args;
2431
}
@@ -33,6 +40,15 @@ server {
3340
}
3441
}
3542

43+
# Redirect http to https
44+
server {
45+
listen 80;
46+
listen [::]:80;
47+
server_name multisite-subdomain.com *.multisite-subdomain.com;
48+
49+
return 301 https://$host$request_uri;
50+
}
51+
3652
# Redirect www to non-www
3753
server {
3854
listen 80;

0 commit comments

Comments
 (0)