複数のドメインを持ち、同じアプリケーション(上流)を指し示すSSL証明書(ドメインごとに1つ)を暗号化します。現在、以下のコードを使用しています。しかし、それはかなりのコードです、特に私はすべてのドメインのためにそれを複製する必要があります。だから私は、コードを一度しか持たないように、それを組み合わせる方法があるのだろうかと思っています。Nginxのセットアップ複数のドメインを個別のSSL証明書を同じアップストリームに設定
https://www.any-domain-here
のリダイレクトは、最後のメインのサーバーブロックと同様に問題があり、両方ともSSL証明書を必要とするため、すべての異なるドメインにそれらを含める必要があります。これらのコードブロックを複製せずにこれを行う方法はありますか?
############################
#
# Upstream
#
upstream upstream {
least_conn;
server app:8080;
}
upstream blog.upstream {
least_conn;
server app_nginx;
}
############################
#
# redirect all 80 to 443
# and allow Let's Encrypt
#
server {
server_name ~.;
listen 80;
listen [::]:80;
# config for .well-known
include /etc/nginx/includes/letsencrypt.conf;
location/{
return 301 https://$host$uri;
}
}
############################
#
# Redirect all www to non-www
#
server {
server_name "~^www\.(.*)$" ;
return 301 https://$1$request_uri ;
ssl_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.domain.com/privkey.pem;
}
##########################
# HTTPS
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name domain.com;
location /blog/ {
proxy_set_header Host $host;
proxy_pass http://blog.upstream;
}
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
# access_log
access_log /var/log/nginx/access.log;
# proxy_pass config
location/{
# include proxy presets
include /etc/nginx/includes/proxy.conf;
proxy_pass http://domain.com$uri;
}
# general ssl parameters
include /etc/nginx/includes/ssl-params-with-preload.conf;
root /var/www/html;
}
これを解決しましたか? – Karem
申し訳ありません@カレム、あなたは以前に質問されていませんでした。 –