質問編集履歴

2

httpのリダイレクトの設定が間違っていたので修正しました

2019/06/07 06:36

投稿

sumagimo
sumagimo

スコア16

test CHANGED
File without changes
test CHANGED
@@ -326,50 +326,50 @@
326
326
 
327
327
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/$
328
328
 
329
+ RewriteRule ^(.*)$ https://aaa.example$1 [R=301,L]
330
+
331
+
332
+
333
+ www.aaa.example.conf
334
+
335
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/$
336
+
337
+ RewriteRule ^(.*)$ https://www.aaa.example$1 [R=301,L]
338
+
339
+
340
+
341
+ www.bbb.example.conf
342
+
343
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/$
344
+
345
+ RewriteRule ^(.*)$ https://www.bbb.example$1 [R=301,L]
346
+
347
+
348
+
349
+ aaa.example-ssl.conf
350
+
351
+ RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
352
+
329
353
  RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
330
354
 
331
355
 
332
356
 
333
- www.aaa.example.conf
357
+ www.aaa.example-ssl.conf
334
-
358
+
335
- RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/$
359
+ RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
336
360
 
337
361
  RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
338
362
 
339
363
 
340
364
 
341
- www.bbb.example.conf
365
+ www.bbb.example-ssl.conf
342
-
366
+
343
- RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/$
367
+ RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
344
368
 
345
369
  RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
346
370
 
347
371
 
348
372
 
349
- aaa.example-ssl.conf
350
-
351
- RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
352
-
353
- RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
354
-
355
-
356
-
357
- www.aaa.example-ssl.conf
358
-
359
- RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
360
-
361
- RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
362
-
363
-
364
-
365
- www.bbb.example-ssl.conf
366
-
367
- RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
368
-
369
- RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
370
-
371
-
372
-
373
373
  ### apacheの設定
374
374
 
375
375
 

1

ドメインを例示用に修正、リダイレクト、apacheの設定を追記

2019/06/07 06:36

投稿

sumagimo
sumagimo

スコア16

test CHANGED
File without changes
test CHANGED
@@ -16,15 +16,15 @@
16
16
 
17
17
 
18
18
 
19
- aaa.jp
19
+ aaa.example
20
-
20
+
21
- www.aaa.jp
21
+ www.aaa.example
22
-
22
+
23
- www.bbb.jp
23
+ www.bbb.example
24
24
 
25
25
  上記3ドメインにLet's Encryptの自動更新のクーロンをセットしたい
26
26
 
27
- ※aaa.jp、www.aaa.jp、www.bbb.jpともに最終的にはccc.jpにリダイレクトさせる
27
+ ※aaa.example、www.aaa.example、www.bbb.exampleともに最終的にはccc.exampleにリダイレクトさせる
28
28
 
29
29
 
30
30
 
@@ -38,27 +38,27 @@
38
38
 
39
39
  2. 証明書の取得
40
40
 
41
- $ sudo certbot certonly --webroot -w /var/www/html/ -d aaa.jp
41
+ $ sudo certbot certonly --webroot -w /var/www/html/ -d aaa.example
42
-
42
+
43
- $ sudo certbot certonly --webroot -w /var/www/html/ -d www.aaa.jp
43
+ $ sudo certbot certonly --webroot -w /var/www/html/ -d www.aaa.example
44
-
44
+
45
- $ sudo certbot certonly --webroot -w /var/www/html/ -d www.bbb.jp
45
+ $ sudo certbot certonly --webroot -w /var/www/html/ -d www.bbb.example
46
46
 
47
47
 
48
48
 
49
49
  ※下記コマンドがエラーになったため取得と設定を別々に作業することにした
50
50
 
51
- ※$ sudo certbot --apache -d aaa.jp -d www.aaa.jp -d www.bbb.jp
51
+ ※$ sudo certbot --apache -d aaa.example -d www.aaa.example -d www.bbb.example
52
52
 
53
53
 
54
54
 
55
55
  3. 証明書の反映
56
56
 
57
- $ sudo vi aaa.jp-ssl.conf
57
+ $ sudo vi aaa.example-ssl.conf
58
-
58
+
59
- $ sudo vi www.aaa.jp-ssl.conf
59
+ $ sudo vi www.aaa.example-ssl.conf
60
-
60
+
61
- $ sudo vi www.bbb.jp-ssl.conf
61
+ $ sudo vi www.bbb.example-ssl.conf
62
62
 
63
63
  それぞれのファイルの証明書の部分を変更
64
64
 
@@ -76,11 +76,11 @@
76
76
 
77
77
  5. それぞれのドメインのhttpsを有効にする
78
78
 
79
- $ sudo a2ensite aaa.jp-ssl.conf
79
+ $ sudo a2ensite aaa.example-ssl.conf
80
-
80
+
81
- $ sudo a2ensite www.aaa.jp-ssl.conf
81
+ $ sudo a2ensite www.aaa.example-ssl.conf
82
-
82
+
83
- $ sudo a2ensite www.bbb.jp-ssl.conf
83
+ $ sudo a2ensite www.bbb.example-ssl.conf
84
84
 
85
85
  ・設定反映
86
86
 
@@ -96,13 +96,13 @@
96
96
 
97
97
  7. 証明書が正しく反映されていることを確認
98
98
 
99
- aaa.jp-ssl.conf
99
+ aaa.example-ssl.conf
100
-
100
+
101
- www.aaa.jp-ssl.conf
101
+ www.aaa.example-ssl.conf
102
-
102
+
103
- www.bbb.jp-ssl.conf
103
+ www.bbb.example-ssl.conf
104
-
104
+
105
- ともに特定のURLはccc.jpにリダイレクトしない除外設定を仕込んで確認
105
+ ともに特定のURLはccc.exampleにリダイレクトしない除外設定を仕込んで確認
106
106
 
107
107
 
108
108
 
@@ -128,7 +128,7 @@
128
128
 
129
129
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
130
130
 
131
- Processing /etc/letsencrypt/renewal/aaa.jp.conf
131
+ Processing /etc/letsencrypt/renewal/aaa.example.conf
132
132
 
133
133
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134
134
 
@@ -140,19 +140,19 @@
140
140
 
141
141
  Performing the following challenges:
142
142
 
143
- http-01 challenge for aaa.jp
143
+ http-01 challenge for aaa.example
144
144
 
145
145
  Waiting for verification...
146
146
 
147
147
  Cleaning up challenges
148
148
 
149
- Attempting to renew cert (aaa.jp) from /etc/letsencrypt/renewal/aaa.jp.conf produced an unexpected error: Failed authorization procedure. aaa.jp (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from https://ccc.jp/ [xxx.xxx.xx.xxx]: "[ccc.jpのindex.htmlの応答]". Skipping.
150
-
151
-
152
-
153
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
154
-
155
- Processing /etc/letsencrypt/renewal/www.bbb.jp.conf
149
+ Attempting to renew cert (aaa.example) from /etc/letsencrypt/renewal/aaa.example.conf produced an unexpected error: Failed authorization procedure. aaa.example (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from https://ccc.example/ [xxx.xxx.xx.xxx]: "[ccc.exampleのindex.htmlの応答]". Skipping.
150
+
151
+
152
+
153
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
154
+
155
+ Processing /etc/letsencrypt/renewal/www.bbb.example.conf
156
156
 
157
157
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
158
158
 
@@ -164,19 +164,19 @@
164
164
 
165
165
  Performing the following challenges:
166
166
 
167
- http-01 challenge for www.bbb.jp
167
+ http-01 challenge for www.bbb.example
168
168
 
169
169
  Cleaning up challenges
170
170
 
171
- Attempting to renew cert (www.bbb.jp) from /etc/letsencrypt/renewal/www.bbb.jp.conf produced an unexpected error: Missing command line flag or config entry for this setting:
171
+ Attempting to renew cert (www.bbb.example) from /etc/letsencrypt/renewal/www.bbb.example.conf produced an unexpected error: Missing command line flag or config entry for this setting:
172
-
172
+
173
- Input the webroot for www.bbb.jp:. Skipping.
173
+ Input the webroot for www.bbb.example:. Skipping.
174
-
175
-
176
-
174
+
175
+
176
+
177
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
177
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
178
-
178
+
179
- Processing /etc/letsencrypt/renewal/www.aaa.jp.conf
179
+ Processing /etc/letsencrypt/renewal/www.aaa.example.conf
180
180
 
181
181
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
182
182
 
@@ -188,21 +188,21 @@
188
188
 
189
189
  Performing the following challenges:
190
190
 
191
- http-01 challenge for www.aaa.jp
191
+ http-01 challenge for www.aaa.example
192
192
 
193
193
  Waiting for verification...
194
194
 
195
195
  Cleaning up challenges
196
196
 
197
- Attempting to renew cert (www.aaa.co.jp) from /etc/letsencrypt/renewal/www.aaa.jp.conf produced an unexpected error: Failed authorization procedure. www.aaa.jp (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from https://ccc.jp/ [xx.xxx.xxx.xxx]: "[ccc.jpのindex.htmlの応答]". Skipping.
197
+ Attempting to renew cert (www.aaa.co.example) from /etc/letsencrypt/renewal/www.aaa.example.conf produced an unexpected error: Failed authorization procedure. www.aaa.example (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from https://ccc.example/ [xx.xxx.xxx.xxx]: "[ccc.exampleのindex.htmlの応答]". Skipping.
198
198
 
199
199
  All renewal attempts failed. The following certs could not be renewed:
200
200
 
201
- /etc/letsencrypt/live/aaa.jp/fullchain.pem (failure)
201
+ /etc/letsencrypt/live/aaa.example/fullchain.pem (failure)
202
-
202
+
203
- /etc/letsencrypt/live/www.bbb.jp/fullchain.pem (failure)
203
+ /etc/letsencrypt/live/www.bbb.example/fullchain.pem (failure)
204
-
204
+
205
- /etc/letsencrypt/live/www.aaa.jp/fullchain.pem (failure)
205
+ /etc/letsencrypt/live/www.aaa.example/fullchain.pem (failure)
206
206
 
207
207
 
208
208
 
@@ -216,11 +216,11 @@
216
216
 
217
217
  All renewal attempts failed. The following certs could not be renewed:
218
218
 
219
- /etc/letsencrypt/live/aaa.jp/fullchain.pem (failure)
219
+ /etc/letsencrypt/live/aaa.example/fullchain.pem (failure)
220
-
220
+
221
- /etc/letsencrypt/live/www.bbb.jp/fullchain.pem (failure)
221
+ /etc/letsencrypt/live/www.bbb.example/fullchain.pem (failure)
222
-
222
+
223
- /etc/letsencrypt/live/www.aaa.jp/fullchain.pem (failure)
223
+ /etc/letsencrypt/live/www.aaa.example/fullchain.pem (failure)
224
224
 
225
225
  ** DRY RUN: simulating 'certbot renew' close to cert expiry
226
226
 
@@ -238,13 +238,13 @@
238
238
 
239
239
 
240
240
 
241
- Domain: aaa.jp
241
+ Domain: aaa.example
242
242
 
243
243
  Type: unauthorized
244
244
 
245
- Detail: Invalid response from https://ccc.jp/
245
+ Detail: Invalid response from https://ccc.example/
246
-
246
+
247
- [xxx.xxx.xxx.xxx]: "[ccc.jpのindex.htmlの応答]"
247
+ [xxx.xxx.xxx.xxx]: "[ccc.exampleのindex.htmlの応答]"
248
248
 
249
249
 
250
250
 
@@ -258,13 +258,13 @@
258
258
 
259
259
 
260
260
 
261
- Domain: www.aaa.jp
261
+ Domain: www.aaa.example
262
262
 
263
263
  Type: unauthorized
264
264
 
265
- Detail: Invalid response from https://ccc.jp/
265
+ Detail: Invalid response from https://ccc.example/
266
-
266
+
267
- [xxx.xxx.xxx.xxx]: "[ccc.jpのindex.htmlの応答]"
267
+ [xxx.xxx.xxx.xxx]: "[ccc.exampleのindex.htmlの応答]"
268
268
 
269
269
 
270
270
 
@@ -292,11 +292,11 @@
292
292
 
293
293
 
294
294
 
295
- aaa.jp.conf
295
+ aaa.example.conf
296
-
296
+
297
- www.aaa.jp.conf
297
+ www.aaa.example.conf
298
-
298
+
299
- www.bbb.jp.conf
299
+ www.bbb.example.conf
300
300
 
301
301
  上記に対してサーバの認証で使用する(と思われる)pathをドキュメントルートに作成し、リダイレクトから除外してhttpで反応するようにした
302
302
 
@@ -315,3 +315,147 @@
315
315
 
316
316
 
317
317
  証明書の取得でサーバ認証PATHに /var/www/html/ を指定したこと
318
+
319
+
320
+
321
+ ### リダイレクトの設定
322
+
323
+
324
+
325
+ aaa.example.conf
326
+
327
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/$
328
+
329
+ RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
330
+
331
+
332
+
333
+ www.aaa.example.conf
334
+
335
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/$
336
+
337
+ RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
338
+
339
+
340
+
341
+ www.bbb.example.conf
342
+
343
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/$
344
+
345
+ RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
346
+
347
+
348
+
349
+ aaa.example-ssl.conf
350
+
351
+ RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
352
+
353
+ RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
354
+
355
+
356
+
357
+ www.aaa.example-ssl.conf
358
+
359
+ RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
360
+
361
+ RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
362
+
363
+
364
+
365
+ www.bbb.example-ssl.conf
366
+
367
+ RewriteCond %{REQUEST_URI} !^/check/$ ※証明書確認のための除外
368
+
369
+ RewriteRule ^(.*)$ https://ccc.example$1 [R=301,L]
370
+
371
+
372
+
373
+ ### apacheの設定
374
+
375
+
376
+
377
+ apache2.conf
378
+
379
+
380
+
381
+ DefaultRuntimeDir ${APACHE_RUN_DIR}
382
+
383
+ PidFile ${APACHE_PID_FILE}
384
+
385
+ Timeout 300
386
+
387
+ KeepAlive On
388
+
389
+ MaxKeepAliveRequests 100
390
+
391
+ KeepAliveTimeout 5
392
+
393
+ User ${APACHE_RUN_USER}
394
+
395
+ Group ${APACHE_RUN_GROUP}
396
+
397
+ HostnameLookups Off
398
+
399
+ ErrorLog ${APACHE_LOG_DIR}/error.log
400
+
401
+ LogLevel warn
402
+
403
+ IncludeOptional mods-enabled/*.load
404
+
405
+ IncludeOptional mods-enabled/*.conf
406
+
407
+ Include ports.conf
408
+
409
+ <Directory />
410
+
411
+ Options FollowSymLinks
412
+
413
+ AllowOverride None
414
+
415
+ Require all denied
416
+
417
+ </Directory>
418
+
419
+
420
+
421
+ <Directory /usr/share>
422
+
423
+ AllowOverride None
424
+
425
+ Require all granted
426
+
427
+ </Directory>
428
+
429
+
430
+
431
+ <Directory /var/www/>
432
+
433
+ Options Indexes FollowSymLinks
434
+
435
+ AllowOverride None
436
+
437
+ Require all granted
438
+
439
+ </Directory>
440
+
441
+ AccessFileName .htaccess
442
+
443
+ <FilesMatch "^.ht">
444
+
445
+ Require all denied
446
+
447
+ </FilesMatch>
448
+
449
+ LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
450
+
451
+ LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
452
+
453
+ LogFormat "%h %l %u %t \"%r\" %>s %O" common
454
+
455
+ LogFormat "%{Referer}i -> %U" referer
456
+
457
+ LogFormat "%{User-agent}i" agent
458
+
459
+ IncludeOptional conf-enabled/*.conf
460
+
461
+ IncludeOptional sites-enabled/*.conf