问题原文
原帖链接 · THE JOATMON · CC BY-SA 4.0
I have Nginx setup and successfully serving SSL to example.com using certbot/letsencrypt. But when I try to reverse proxy to a local machine I get NET::ERR_CERT_COMMON_NAME_INVALID. Here's the basic setup
| role | name | ip |
|---|---|---|
| Nginx server | example.com | 192.168.1.1 |
| Web server | test01.example.com | 192.168.1.10 |
| Web server | test02.example.com | 192.168.1.11 |
Both web servers are currently using self-signed certs. I can access them internally via https://192.168.1.10:8443. But again, if I try to access https://test01.example.com I get NET::ERR_CERT_COMMON_NAME_INVALID.
Here is my basic config:
server {
listen 443 ssl http2;
server_name example.com;
root /usr/share/nginx/html/;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
include ssl.conf;
}
server {
listen 443;
server_name test01.example.com;
location / {
proxy_pass $scheme://192.168.1.10:8443;
}
}
I'll probably have over 20 of these web servers. Do I need to generate a cert for each one?
已采纳解答
原帖链接 · THE JOATMON · CC BY-SA 4.0
I was able to get this to work with a wildcard cert. I generated the cert with certbot using this command:
sudo certbot certonly --agree-tos --email emailaddress --manual --preferred-challenges=dns -d *.example.com --server https://acme-v02.api.letsencrypt.org/directory
I then added ssl_certificate and ssl_certificate_key directives to the server block. I did this with an include so I don't have to duplicate the lines for every subdomain.
wildcard.conf
ssl_certificate /etc/letsencrypt/live/example.com-wc/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com-wc/privkey.pem;
nginx.conf
server { listen 443 ssl; server_name test01.example.com; include wildcard.conf; location / { proxy_redirect off; proxy_pass $scheme://192.168.1.10:8443; } }
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
