質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
86.02%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

解決済

サイトをhttps化したい

ETO3
ETO3

総合スコア44

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

2回答

0グッド

0クリップ

684閲覧

投稿2022/06/09 01:56

さくらVPSを使用しています。
centos7でdocker を動かしサイトを運用しています。
dockerではphp,web,mariadb,phpmyadminの4つのコンテナが動いています。
https化しようと思ってるのですがなかなか上手くいかず手詰まっています。
ご助力頂きたいです。

現状
普通のhttpでサイトは開ける状況です。
httpsで接続すると「接続が拒否されました。」と出ます。

やったこと

Let’s Encryptでssl証明ができるとあるので手順を調べやろうとしていました。
まずはcertbotを使うそうなので試してみました。

# certbot --apache -d [*********].vs.sakura.ne.jp

上記のコマンドを走らせたところ以下のように帰っってきました。

# certbot --apache -d [*********].vs.sakura.ne.jp Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator apache, Installer apache Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org Requesting a certificate for [*********].vs.sakura.ne Performing the following challenges: http-01 challenge for [*********].vs.sakura.ne Error while running apachectl graceful. Job for httpd.service invalid. Unable to restart apache using ['apachectl', 'graceful'] Error while running apachectl restart. Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details. Cleaning up challenges Error while running apachectl graceful. Job for httpd.service invalid. Unable to restart apache using ['apachectl', 'graceful'] Error while running apachectl restart. Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details. Encountered exception during recovery: MisconfigurationError: Error while running apachectl restart. Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details. Error while running apachectl restart. Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

上記の通りに systemctl status httpd.serviceを入力してみたら以下のようになりました。

# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 水 2022-06-08 16:35:13 JST; 1h 27min ago Docs: man:httpd(8) man:apachectl(8) Process: 985 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE) Main PID: 985 (code=exited, status=1/FAILURE) 6月 08 16:35:13 [*********].vs.sakura.ne.jp systemd[1]: Starting The Apache HTTP Server... 6月 08 16:35:13 [*********].vs.sakura.ne.jp httpd[985]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf/httpd.conf:355 6月 08 16:35:13 [*********].vs.sakura.ne.jp httpd[985]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 6月 08 16:35:13 [*********].vs.sakura.ne.jp httpd[985]: no listening sockets available, shutting down 6月 08 16:35:13 [*********].vs.sakura.ne.jp httpd[985]: AH00015: Unable to open logs 6月 08 16:35:13 [*********].vs.sakura.ne.jp systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE 6月 08 16:35:13 [*********].vs.sakura.ne.jp systemd[1]: Failed to start The Apache HTTP Server. 6月 08 16:35:13 [*********].vs.sakura.ne.jp systemd[1]: Unit httpd.service entered failed state. 6月 08 16:35:13 [*********].vs.sakura.ne.jp systemd[1]: httpd.service failed.

(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
6月 08 16:35:13 [*********].vs.sakura.ne.jp httpd[985]: no liste
とあるのでなんとなく80番ポートが使用されているので使えないんだろうなと言うのはわかるのですが、
80番はdocker のwebコンテナで使用しています。
dockerのコンテナを落とすわけにもいかない気がするのですが、
この場合どうしたら良いのでしょう?

質問内容

上記のようにサーバー内でdocekrを動かしている場合どのようにhttps化すれば良いのでしょうか?
方針がわからず困っています。
ご助力のほどよろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもマイページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

下記のような質問は推奨されていません。

  • 質問になっていない投稿
  • スパムや攻撃的な表現を用いた投稿

適切な質問に修正を依頼しましょう。

回答2

0

It is essentially great idea to protect your website with SSL from leading providers in order to offer safe and reliable experience to your visitors to website diploma assignment writing however there were some server issues which could not have been resolved unless I past the documentation here.

投稿2023/01/30 09:54

jamsam

総合スコア4

下記のような回答は推奨されていません。

  • 質問の回答になっていない投稿
  • スパムや攻撃的な表現を用いた投稿

このような回答には修正を依頼しましょう。

0

ベストアンサー

一番楽なのはnginx-proxyを使うことだと思います。
コンテナに入ってコマンド叩くとかもほとんどしなかった気がします。

参考)
https://it-web-life.com/docker-ssl-nginx-proxy/
https://qiita.com/ohhara_shiojiri/items/193d416ee8ba70d656aa

他にもcertbotのDockerイメージを使う方法もあるみたいです(私は試したことないのでよく分かりませんが)
https://blog.panicblanket.com/archives/6759

ご自分の環境に合わせて良さげなのを選ばれたら良いと思います。

投稿2022/06/09 02:29

AbeTakashi

総合スコア4026

下記のような回答は推奨されていません。

  • 質問の回答になっていない投稿
  • スパムや攻撃的な表現を用いた投稿

このような回答には修正を依頼しましょう。

回答へのコメント

ETO3

2022/06/10 04:22

参考リンクありがとうございます!やってみます!

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
86.02%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問

同じタグがついた質問を見る

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです