質問編集履歴
1
コードの修正と参考サイトの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,9 +22,9 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
【
|
25
|
+
【やりたいこと】
|
26
26
|
|
27
|
-
httpsを含むwwwありなしの
|
27
|
+
httpsを含むwwwありなしへのアクセスを下記のように統一したい
|
28
28
|
|
29
29
|
http://example.com → https://example.com
|
30
30
|
|
@@ -34,7 +34,9 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
+
【修正前】
|
38
|
+
|
37
|
-
```
|
39
|
+
```
|
38
40
|
|
39
41
|
server {
|
40
42
|
|
@@ -72,7 +74,69 @@
|
|
72
74
|
|
73
75
|
ssl on;
|
74
76
|
|
77
|
+
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
|
78
|
+
|
79
|
+
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
【修正後】
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
server {
|
92
|
+
|
93
|
+
listen 80;
|
94
|
+
|
95
|
+
listen [::]:80;
|
96
|
+
|
97
|
+
server_name example.com;
|
98
|
+
|
99
|
+
return 301 https://$host$request_uri;
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
# http(s)://www.example.comへのアクセスをリダイレクト
|
106
|
+
|
107
|
+
server {
|
108
|
+
|
109
|
+
listen 80;
|
110
|
+
|
111
|
+
listen 443;
|
112
|
+
|
113
|
+
server_name www.exmaple.com;
|
114
|
+
|
115
|
+
|
116
|
+
|
75
|
-
|
117
|
+
# 追記
|
118
|
+
|
119
|
+
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
|
120
|
+
|
121
|
+
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
|
122
|
+
|
123
|
+
return 301 https://example.com$request_uri;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
server {
|
130
|
+
|
131
|
+
listen 443 ssl default_server; #修正
|
132
|
+
|
133
|
+
server_name example.com;
|
134
|
+
|
135
|
+
ssl on;
|
136
|
+
|
137
|
+
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
|
138
|
+
|
139
|
+
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
|
76
140
|
|
77
141
|
}
|
78
142
|
|
@@ -94,6 +158,8 @@
|
|
94
158
|
|
95
159
|
|
96
160
|
|
97
|
-
【参考にした
|
161
|
+
【参考にしたサイト】
|
98
162
|
|
99
163
|
[常時SSL化 nginx でリダイレクト www ありに統一](https://www.ts-soft.net/archives/182)
|
164
|
+
|
165
|
+
[Nginx で http も https も IP 直打ちのアクセスを弾きたい←追記](http://beniyama.hatenablog.jp/entry/2015/04/05/100000)
|