问题原文
原帖链接 · hbquikcomjamesl · CC BY-SA 4.0
I have a subdomain set up in Apache httpd, that is front-ending for a Tomcat server, with the httpd server secured by Let's Encrypt.
If I have the following rewrite active in the conf file, then certbot fails.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
If I comment it out, then certbot works.
I'm not entirely sure, but I think it's 100% consistent. Of course, with challenge-caching, I can't get another meaningful test result for a full month after a successful renewal.
已采纳解答
原帖链接 · Andrew Schulman · CC BY-SA 4.0
If I understand correctly, you want to redirect all non-HTTPS requests to HTTPS. So I guess your rewrites are in a <VirtualHost *:80> container, for a non-HTTPS site.
Now you want to add another condition, to not redirect Lets Encrypt challenges. I think you're probably using the HTTP-01 challenge, which means you want to not redirect requests to http://<YOUR_DOMAIN>/.well-known/acme-challenge/<TOKEN>. So does the following work?
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
