У меня есть пара веб-доменов за обратным прокси в Docker ... В качестве контекста приведен фрагмент из docker-compose.yml:
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginxREVERSE
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
site1:
container_name: 'nginxsite1'
image: nginx:latest
volumes:
- ./sites-available/site1.com/index.html:/usr/share/nginx/html/index.html
- ./sites-available/site1.com/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- 8080:80
environment:
- VIRTUAL_HOST=site1.com,www.site1.com
- VIRTUAL_PORT:80
- VIRTUAL_PORT:443
site2:
container_name: 'nginxsite2'
image: nginx:latest
volumes:
- ./sites-available/site2.com/index.html:/usr/share/nginx/html/index.html
ports:
- 8082:80
environment:
- VIRTUAL_HOST=site2.com,www.site2.com
- VIRTUAL_PORT:80
И это прекрасно работает в моем браузере.Я могу перейти на site1.com/www.site1.com или site2.com/www.site2.com и получить доступ к правильной странице Index.html.
Файл nginx.conf на Site1.com:
server {
listen 80;
listen [::]:80;
server_name site1.com www.site1.com;
location ~ /.well-known/acme-challenge {
allow all;
root /usr/share/nginx/html;
}
root /usr/share/nginx/html;
index index.html;
}
Я запускаю Certbot в докере с помощью этой команды:
sudo docker run -it --rm \
-v /docker-volumes/etc/letsencrypt:/etc/letsencrypt \
-v /docker-volumes/var/lib/letsencrypt:/var/lib/letsencrypt \
-v /docker/letsencrypt-docker-nginx/src/letsencrypt/letsencrypt-site:/data/letsencrypt \
-v "/docker-volumes/var/log/letsencrypt:/var/log/letsencrypt" \
certbot/certbot \
certonly --webroot \
--register-unsafely-without-email --agree-tos \
--webroot-path=/data/letsencrypt \
--staging \
-d site1.com -d www.site1.com
Когда я перенаправляю напрямую с маршрутизатора на контейнер site1.com, выше работает.
Когда я перенаправляю на обратный прокси-сервер, я получаю ошибку 404 от Certbot:
Failed authorization procedure. site1.com (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorizatin :: Invalid response from http://site1.com/.well-known/acme-challenge/x05mYoqEiWlrRFH9ye6VZfEiX-mlwEffVt2kP3twoOU: "<html>\r\n<head><ttle>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.15.5</ce", www.site1.com (ttp-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.site1/.well-known/acme-challenge/AIDgGYg1WiQRm4-dOVK6fV8-vKqR940nLPzT9poFUZA: "<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.15.5</ce"
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: site1.com
Type: unauthorized
Detail: Invalid response from
http://site1.com/.well-known/acme-challenge/x05mYoqEiWlrRFH9ye6VZfEiX-mlwEOU:
"<html>\r\n<head><title>404 Not
Found</title></head>\r\n<body>\r\n<center><h1>404 Not
Found</h1></center>\r\n<hr><center>nginx/1.15.5</ce"
Domain: www.site1.com
Type: unauthorized
Detail: Invalid response from
http://www.site1.com/.well-known/acme-challenge/AIDgGYg1WiQRm4-dOVK6fV8-poFUZA:
"<html>\r\n<head><title>404 Not
Found</title></head>\r\n<body>\r\n<center><h1>404 Not
Found</h1></center>\r\n<hr><center>nginx/1.15.5</ce"
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
Чего мне не хватает, что позволяет мне получать доступ к сайтам за обратным прокси из моего браузера, но не позволяетCerbot