Railsアプリをデプロイしようとしています。
さくらのVPSで複数ドメイン(2つ)を利用したいのですが、設定の方法でわからない点があるので教えていただけないでしょうか?
現状は、1つのドメインでSSL通信出来る状態で、デプロイ前の状態です。
ドメインをもう一つ追加し、2つのドメインを運用したいのです。
1つ目のドメイン設定ファイルは /etc/nginx/conf.d/https.confでした。
これはさくらのVPSに申込時に設定されていたファイルです。
このファイルはhttps://example.com用のファイルです。
これをhttps://hogehoge.jpでもアクセス出来るようにしたいのです。
間違っているかもしれませんが
サイト等で調べてみたらもう一つhogehoge.jp用のファイルを作ればいいような感じでした。例えば /etc/nginx/conf.d/vhost.confみたいなファイル名でhttps.confの内容をコピーしhogehoge.jp用に修正を加えればいいというように認識しています。
example.comのSSL設定ファイルは以下になっています。
/etc/nginx/conf.d/https.conf upstream app_server { server unix:/usr/share/nginx/html/current/tmp/sockets/.unicorn.sock fail_timeout=0; } map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 443 ssl http2; server_name example.com; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { deny 212.64.88.231; deny 181.24.23.164; allow all; root /usr/share/nginx/html/current/public; index index.html index.htm; try_files $uri/index.html $uri.html $uri @app; } ssl_protocols TLSv1.2; ssl_ciphers EECDH+AESGCM:EECDH+AES; ssl_ecdh_curve prime256v1; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; proxy_connect_timeout 130; proxy_read_timeout 130; proxy_send_timeout 130; client_max_body_size 2G; error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html/current/public; } error_page 500 502 504 /50x.html; location = /500.html { root /usr/share/nginx/html/current/public; } location @app { deny 212.64.88.231; deny 181.24.23.164; allow all; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } set $maintenance false; if (-e /var/tmp/do_maintenance) { set $maintenance true; } if ($uri ~ "^/maintenance/") { set $maintenance false; } if ($remote_addr = XXX.XXX.X.XXX) { set $maintenance false; } error_page 503 /maintenance/maintenance.html; location /maintenance/ { root /var/www; } if ($maintenance = true) { return 503; } }
その中にSSLのkey設定の箇所が2行ありました。
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pen ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pen
example.comはこの状態でSSL通信出来ているのですがhogehoge.jpを設定する場合も
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pen ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pen
と同じ記述をすればいいのでしょうか?
SSLのkeyは同じものを使うと思うので同じでいいのかとも思いますが、
ssl_certificate /etc/letsencrypt/live/hogehoge.jp/fullchain.pen ssl_certificate_key /etc/letsencrypt/live/hogehoge.jp/privkey.pen
上のようにしてもそのようなkeyは無いと思うので同じ設定でいいような感じもするのです。
複数のドメインを設定するのが初めてなのでどなたかご教授お願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/08 06:26