apache CentOS Let's Encrypt Nextcloud Nginx

Nextcloud 16 + Nginx(リバプロ) + CentOS 7.7 + Apache 2.4.6

apache

Nextcloudのインストール編

CentOSのインストールは省いてます

リバースプロキシー経由でWebサーバーにアクセスする場合のSSL証明書リバースプロキシーに設定する。リバースプロキシーからWebサーバーへの通信はhttpで良い様です。情報少ない。

環境 構成

Nextcloudへのアクセス構成は
クライアント →https→ リバースプロキシー(CnetOS 6.9 Nginx)→http→ Nextcloud 16(CentOS 7.7 Apache 2.4.6)
リバースプロキシーの理由は単純にグローバルアドレスが不足しているからです(笑)
ただ、プロキシキーのキャッシュが利用できて有利かもしれません。

Nextcloudのインストール(CentOS 7.7)

サーバー環境設定

CentOS 7.7のパッケージを最新の状態に

[root@nextsv ~]# yum update

Nextcloud のインストールに必要なパッケージをインストール

[root@nextsv ~]# yum install -y epel-release yum-utils unzip curl wget git bash-completion policycoreutils-python

Apacheのインストール

[root@nextsv ~]# yum install -y httpd

PHP 7.2のインストール(失敗)

[root@nextsv ~]# yum install -y rh-php72 rh-php72-php rh-php72-php-gd rh-php72-php-mbstring rh-php72-php-intl rh-php72-php-pecl-apcu rh-php72-php-mysqlnd rh-php72-php-pecl-redis rh-php72-php-opcache rh-php72-php-imagick
このパッケージは利用できません。

リポジトリにphp72があるか確認

[root@nextsv ~]# yum list available | grep php72

何も返らないのでないものと思われる。
以前の私の下記投稿記事のphp7.1のインストールを参考に7.1を7.2に変更してインストールしてみた

[root@nextsv ~]# yum install epel-release
[root@nextsv ~]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

[root@nextsv ~]# yum install --enablerepo=remi,remi-php72 php php-gd php-json php-mysql php-curl php-mbstring
[root@nextsv ~]# yum install --enablerepo=remi,remi-php72 php-intl php-mcrypt php-imagick php-xml php-zip php-process php-apcu

[root@nextsv ~]# php --version
PHP 7.2.23 (cli) (built: Sep 25 2019 07:38:48) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

シンボリックリンクを張る

[root@nextsv conf.d]# ln -s /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php72-php.conf /etc/httpd/conf.d/
[root@nextsv opt]# ln -s /opt/rh/httpd24/root/etc/httpd/conf.modules.d/15-rh-php72-php.conf /etc/httpd/conf.modules.d/
[root@nextsv opt]# ln -s /opt/rh/httpd24/root/etc/httpd/modules/librh-php72-php7.so /etc/httpd/modules/
[root@nextsv opt]# ln -s /opt/rh/rh-php72/root/bin/php /usr/bin/php
ln: シンボリックリンク `/usr/bin/php' の作成に失敗しました: ファイルが存在します

とりあえず php 7.2 のインストールは中断して先に進む。後でphp 7.2をインストール

MariaDB のインストール・設定

[root@nextsv opt]# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
[info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo.
[info] Adding trusted package signing keys...
[info] Successfully added trusted package signing keys.

[root@nextsv opt]# yum install -y mariadb mariadb-server

MariaDBの設定

[root@nextsv opt]# vi /etc/my.cnf.d/server.cnf

[mysqld] の所に下記を追加した
character-set-server = utf8
innodb_buffer_pool_size=1G
innodb_io_capacity=4000
innodb_large_prefix=true
innodb_file_format=barracuda
innodb_file_per_table=1

MariaDB を起動

# systemctl start mariadb

自動起動設定を追加

# systemctl enable mariadb

MariaDBの初期設定
※インストーラの指示に従ってmysqlのrootパスワード等を設定
パスワード password

[root@nextsv opt]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n]
Enabled successfully!
Reloading privilege tables..
... Success!

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] n
... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

MariaDB にログイン

# mysql -u root -p

※パスワードの入力を求められるので先ほど設定したmysqlのrootパスワードを入力
ログインできるとプロンプトが表示されます。

MariaDB [(none)]>

データベースを作成

[root@nextsv opt]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.4.8-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE nextcloud;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> GRANT ALL ON nextcloud.* to nextcloud@'localhost' identified by 'password';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> exit
Bye

以下の情報でデータベースを作成

データベース名 nextcloud
データベースユーザー名 nextcloud
データベースパスワード password
※安全なパスワードを設定

Nextcloud のインストール

Nextcloudの最新パッケージのダウンロードURLを確認

Nextcloud Download Page
https://nextcloud.com/install/
◇Download for server > Archive file > Download Nextcloud

確認したURLでサーバーにNextcloudをインストール

バージョン16.0.5を /var/www/html/nextcloudにインストール

[root@nextsv ~]# wget https://download.nextcloud.com/server/releases/nextcloud-16.0.5.zip
[root@nextsv ~]# unzip nextcloud-16.0.5.zip -d /var/www/html

データドライブがOS領域では小さいので別に作る

[root@nextsv home]# mkdir /home/nextcloud
[root@nextsv home]# mkdir /home/nextcloud/data
[root@nextsv home]# chown -fR apache:apache /home/nextcloud
[root@nextsv nextcloud]# chown -R apache:apache /var/www/html/nextcloud

Apache の設定ファイルを追加します。

[root@nextsv nextcloud]# vi /etc/httpd/conf.d/nextcloud.conf

[root@nextsv conf.d]# cat nextcloud.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/nextcloud/
 ServerName mydomain.xxx

<Directory "/var/www/html/nextcloud/">
 Require all granted
 AllowOverride All
 Options FollowSymLinks MultiViews
 <IfModule mod_dav.c>
  Dav off
 </IfModule>
</Directory>

</VirtualHost>

<Directory "/home/nextcloud/data/">
 Require all denied
</Directory>

Redirect 301 /.well-known/carddav /nextcloud/remote.php/dav
Redirect 301 /.well-known/caldav /nextcloud/remote.php/dav
Redirect 301 /.well-known/webfinger /nextcloud/public.php?service=webfinger

SELINUXの無効化

vi /etc/selinux/config
SELINUX=enforcing → disabled に変更

Apache を起動します。

[root@nextsv ~]# systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

エラー発生 Apache起動失敗

[root@nextsv ~]# systemctl status httpd -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 木 2019-10-10 14:46:17 JST; 3min 7s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 9498 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 9497 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 9497 (code=exited, status=1/FAILURE)

10月 10 14:46:16 nextsv systemd[1]: Starting The Apache HTTP Server...
10月 10 14:46:17 nextsv httpd[9497]: httpd: Syntax error on line 56 of /etc/httpd/conf/httpd.conf: Could not open configuration file /etc/httpd/conf.modules.d/15-rh-php72-php.conf: No such file or directory

httpd 起動に失敗するのでPHP 7.2の再インストール

まずSCLリポジトリのインストール

yum install centos-release-scl

PHP 7.2とモジュールのインストール

yum install rh-php72 rh-php72-php rh-php72-php-gd rh-php72-php-mbstring rh-php72-php-intl rh-php72-php-pecl-apcu

MySQL/MariaDB用 PHP 7.2 モジュールのインストール

yum install rh-php72-php-mysqlnd

古いバージョンの PHP Apacheモジュールを利用できないようにファイル名変更

mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php54.off

実体へシンボリックリンクを張ります

ln -s /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php72-php.conf /etc/httpd/conf.d/
ln -s /opt/rh/httpd24/root/etc/httpd/conf.modules.d/15-rh-php72-php.conf /etc/httpd/conf.modules.d/
ln -s /opt/rh/httpd24/root/etc/httpd/modules/librh-php72-php7.so /etc/httpd/modules/

Apacheの再起動 ファイアウォールの確認

systemctl restart httpd.service

ブラウザから http://IPアドレス/

このページは動作していませんnextsvのIP からデータが送信されませんでした。
ERR_EMPTY_RESPONSE

ファイアウォールか? telnet で確認しようとしたが使えないのでインストール

[root@nextsv log]# yum install telnet

telnet 80 でアクセスしてみたら OKっぽい。

[root@nextsv modules]# telnet nextsvのIP 80
Trying nextsvのIP...
Connected to nextsvのIP.

ファイアウォールか? ポート80の記述が見当たらないので問題なさそう?

[root@nextsv httpd]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports:             ← 80が無いので問題ないはず
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:

だが /var/log/messagesを確認すると FINAL_REJECT DPT=80 で80は拒否されている

[root@nextsv log]# grep NextcloudクライアントIP messages
Oct 11 11:15:59 nextsv kernel: FINAL_REJECT: IN=eth0 OUT= MAC=00:15:5d:01:0d:3a:70:4c:a5:89:9c:fb:08:00 SRC=NextcloudクライアントIP DST=nextsvのIP LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=49836 DF PROTO=TCP SPT=50719 DPT=80 WINDOW=14600 RES=0x00 SYN URGP=0
O

試しにファイアウォールを停止してみる

[root@nextsv httpd]# systemctl stop firewalld
[root@nextsv httpd]# firewall-cmd --state
not running

Nextcloudの「管理者アカウントを作成してください」の画面がやっと出た!
やはり、ファイアウォールの設定に問題あり
ファイアウォールを起動して再確認確認

[root@nextsv httpd]# systemctl start firewalld

ログに何も残らないので原因究明困難なのでログに出力設定

[root@nextsv httpd]# firewall-cmd --set-log-denied all
success

ログ出力を停止

[root@nextsv log]# sysctl kernel.printk
kernel.printk = 4 4 1 7
[root@nextsv log]# sysctl -w kernel.printk="3 4 1 7"
kernel.printk = 3 4 1 7

これをやっても /var/log/messages にログが出力続ける。
下の様にして止めた。

[root@nextsv log]# firewall-cmd --set-log-denied=off
success

ポートは開いていてもサービスの許可も必要っぽい。firewall のサービスの確認
全て確認

[root@nextsv log]# firewall-cmd --list-all-zones

firewall のサービスの確認 httpが無い!

[root@nextsv log]# firewall-cmd --zone=public --list-services --permanent
dhcpv6-client ssh

ファイアウォールの設定でhttpサービスの追加

[root@nextsv log]# firewall-cmd --add-service=http --zone=public --permanent
success

httpサービスが追加されたことが確認できた

[root@nextsv ~]# firewall-cmd --zone=public --list-services --permanent
dhcpv6-client http ssh

内部のhttpサービスの確認 httpが無い

[root@nextsv log]# firewall-cmd --zone=internal --list-services --permanent
dhcpv6-client mdns samba-client ssh

内部internal にhttpサービスの追加(最終的に内部にはこの設定は不要だった)

[root@nextsv log]# firewall-cmd --add-service=http --zone=internal --permanent
success

内部のhttpサービスの確認 httpが追加された

[root@nextsv ~]# firewall-cmd --zone=internal --list-services --permanent
dhcpv6-client http mdns samba-client ssh

ファイアウォール再起動

[root@nextsv log]# firewall-cmd --reload
success

この状態で http://nextsvのIP/ で開いた
これでnextcloudの最初の画面が出た。

dnsサーバーの設定

nextcloud-server      IN A        xxx.xxx.xxx.xxx   (リバースプロシキーのグローバルIP)
webserver1            IN A        xxx.xxx.xxx.xxx   (リバースプロシキーのグローバルIP)
webserver2            IN A        xxx.xxx.xxx.xxx   (リバースプロシキーのグローバルIP)

nginx(CentOS 6.9) リバースプロキシーとLet’s Encryptの設定

Pythonをインストール

Pyenvを使うために必要なライブラリなどをインストール(CentOSの場合)

[root@nginxsv ~]# yum install gcc gcc-c++ make git openssl-devel bzip2-devel zlib-devel readline-devel sqlite-devel bzip2 sqlite zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel

Pyenvをインストール

[root@nginxsv ~]# git clone git://github.com/yyuu/pyenv.git

Pyenvにパスが通るように ~/.bashrc編集してパスを有効にする

[root@nginxsv ~]# cd /root/pyenv
[root@nginxsv pyenv]# vi ~/.bashrc
[root@nginxsv pyenv]# cat ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
 . /etc/bashrc
fi

export PYENV_ROOT="/root/pyenv"
if [ -d "${PYENV_ROOT}" ]; then
 export PATH=${PYENV_ROOT}/bin:$PATH
 eval "$(pyenv init -)"
fi

[root@nginxsv pyenv]# source ~/.bashrc
[root@nginxsv pyenv]# pyenv
pyenv 1.2.13-19-gf3d008f
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
commands List all available pyenv commands
local Set or show the local application-specific Python version
global Set or show the global Python version
shell Set or show the shell-specific Python version
install Install a Python version using python-build
uninstall Uninstall a specific Python version
rehash Rehash pyenv shims (run this after installing executables)
version Show the current Python version and its origin
versions List all Python versions available to pyenv
which Display the full path to an executable
whence List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme

エラーが出てなさそうなのでパスが通ったと思われる。
インストール可能なPythonのバージョンを調べる

[root@nginxsv pyenv]# pyenv install --list

今のバージョンは

[root@nginxsv pyenv]# python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Pyenvを使ってPythonをインストール

参考サイトに合わせて ここではPython2.7.13をインストールします

[root@nginxsv pyenv]# pyenv install 2.7.13
Downloading Python-2.7.13.tar.xz...
-> https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
Installing Python-2.7.13...
Installed Python-2.7.13 to /root/pyenv/versions/2.7.13

インストールしたPythonを使えるようにする

[root@nginxsv pyenv]# pyenv global 2.7.13

インストール結果を確認

[root@nginxsv conf.d]# python
Python 2.7.13 (default, Oct 15 2019, 14:42:03)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

エラーが出てないのでインストール完了の様です。

Let’s EncryptからSSL証明書を取得する

証明書の確認のための専用のパスを作成する

certbotを使って証明書を取得する際、サーバーが存在するか、チェックが行われます。
このチェックに対応するために専用のパスを作成する必要があります。
「Nginxのドキュメントルート以下」にディレクトリを作成する ← 「nginxのルートディレクトリ以下」の間違い?
ドキュメントルートは[nginxのルートディレクトリ]/conf.d/default.confで確認できます。
今回の場合は以下に記載されている内容です。

[root@nginxsv conf.d]# pwd
/etc/nginx/conf.d

/etc/nginx/conf.d/default.conf の内容

location / {
root /usr/share/nginx/html; ← ドキュメントルート
index index.html index.htm;
}

■nginxのルートディレクトリ /etc/nginx
■ドキュメントルート     /usr/share/nginx/html

よって以下のようにドキュメントルートからパスを設定するために空のディレクトリを作成します。
nginxのルートディレクトリに移動

[root@nginxsv conf.d]# cd /etc/nginx

mkdir [nginxのルートディレクトリ]/html/.well-known

[root@nginxsv html]# mkdir /etc/nginx/html/.well-known

次に、作成したパスをnginx側で使えるようにするために、[nginxのルートディレクトリ]/nginx.confを編集します。
/etc/nginx/nginx.conf を編集

http{
...
server {
listen 80;
listen 443 ssl;
server_name mydomain.xxx;
ssl_certificate /etc/letsencrypt/live/mydomain.xxx/fullchain.pem; ← Let's Encrypt未インストールなのでエラー
ssl_certificate_key /etc/letsencrypt/live/mydomain.xxx/privkey.pem; ← Let's Encrypt未インストールなのでエラー
client_max_body_size 2048m;

location ^~ /.well-known/acme-challenge/ {   ← これ
root /usr/share/nginx/html/.well-known;        ← これ
}

location / {
proxy_set_header X-Real-IP $remote_addr;
index index.html index.htm;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://nextsvのIP/;
}
}

}

その後、nginxを再起動して、変更内容を適用
まだLet’s EncryptのSSL証明書が無いのでエラー

[root@nginxsv nginx]# service nginx restart 
nginx: [emerg] BIO_new_file("/etc/letsencrypt/live/mydomain.xxx/fullchain.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/mydomain.xxx/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed

certbotを(Gitを使って)インストールする

certbotとはLet’s Encrypt が提供しているツールであり、Let’s Encrypt と通信するエージェント(クライアント)です。
Gitを使わない方法もありますが今回はGitを使った方法でインストールします。

[root@nginxsv ~]# git clone https://github.com/certbot/certbot
Initialized empty Git repository in /root/certbot/.git/
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 69382 (delta 0), reused 2 (delta 0), pack-reused 69370
Receiving objects: 100% (69382/69382), 22.81 MiB | 3.84 MiB/s, done.
Resolving deltas: 100% (50869/50869), done.

certbotを使って証明書を取得(失敗)

[root@nginxsv ~]# cd
[root@nginxsv ~]# cd certbot/
[root@nginxsv certbot]# ./certbot-auto certonly
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] BIO_new_file("/etc/letsencrypt/live/mydomain.xxx/fullchain.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/mydomain.xxx/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed

失敗した

/etc/nginx/nginx.conf でエラーになる次の2行をコメントアウトしてみた

# ssl_certificate /etc/letsencrypt/live/mydomain.xxx/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/mydomain.xxx/privkey.pem;

これで

[root@nginxsv nginx]# service nginx restart
nginx を停止中: [ OK ]
nginx を起動中: [ OK ]

これでnginxは一応起動できた。

再度 certbotを使って証明書を取得 各種設定

[root@nginxsv certbot]# pwd
/root/certbot
[root@nginxsv certbot]# ./certbot-auto certonly
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Apache Web Server plugin (apache)
2: Nginx Web Server plugin (nginx)
3: Spin up a temporary webserver (standalone)
4: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-4] then [enter] (press 'c' to cancel): 4
Plugins selected: Authenticator webroot, Installer None
Please enter in your domain name(s) (comma and/or space separated) (Enter 'c'
to cancel): mydomain.xxx
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mydomain.xxx
Input the webroot for mydomain.xxx: (Enter 'c' to cancel): /usr/share/nginx/html/.well-known
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/mydomain.xxx/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/mydomain.xxx/privkey.pem
Your cert will expire on 2020-01-13. To obtain a new or tweaked
version of this certificate in the future, simply run certbot-auto
again. To non-interactively renew *all* of your certificates, run
"certbot-auto renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

うまくいった?確認

[root@nginxsv mydomain.xxx]# pwd
/etc/letsencrypt/live/mydomain.xxx
[root@nginxsv mydomain.xxx]# ls -l
合計 4
-rw-r--r-- 1 root root 692 10月 15 23:27 2019 README
lrwxrwxrwx 1 root root 39 10月 15 23:27 2019 cert.pem -> ../../archive/mydomain.xxx/cert1.pem
lrwxrwxrwx 1 root root 40 10月 15 23:27 2019 chain.pem -> ../../archive/mydomain.xxx/chain1.pem
lrwxrwxrwx 1 root root 44 10月 15 23:27 2019 fullchain.pem -> ../../archive/mydomain.xxx/fullchain1.pem
lrwxrwxrwx 1 root root 42 10月 15 23:27 2019 privkey.pem -> ../../archive/mydomain.xxx/privkey1.pem

証明書が出来ているので成功したのかも。
/etc/nginx/nginx.conf の先ほどコメントアウトした2行のコメントアウトをはずす

ssl_certificate /etc/letsencrypt/live/mydomain.xxx/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.xxx/privkey.pem;

nginxを再起動してリバースプロキシーに問題ないか確認

[root@nginxsv nginx]# service nginx restart
nginx を停止中: [ OK ]
nginx を起動中: [ OK ]

所感

  • phpのインストールが大変 phpのバージョンを上げるとなると憂鬱 OSSってこういうものか
  • リバースプロキシーを使っているのでその分インストールが複雑。情報も少ない。
  • リバースプロシキー側にSSL証明書を入れるのかNextcloud側に入れるのか判らなかった。
  • 当初Nextcloud側にSSL証明書を入れたがダメだった。
  • Nextcloudの初期画面が出るまで大変だ。

コメント