NginxでSSL接続を行う。 | sy-engのブログ

sy-engのブログ

システムを作りたい。
自分用の記録。

https://kitsune.blog/nginx-ssl

デフォルトでは/etc/nginx/conf.d/の下に何もなかったので、ssl.confを作り、nginxの設定を記載。

(よく見たら/etc/nginx/sites-available/defaultがあった。ただし、ssl.confはそのままとした。)

/etc/nginx/nginx.confに追記しても、エラーが出る。

また、ssl.confは以下のようにした。

一部だけだと、phpが見つからない。

server {
    listen 443 ssl;

    ssl_certificate     /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;

    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }

}
 

そのままだとCHROMEでERR_SSL_SERVER_CERT_BAD_FORMATとなるので、以下の対策が必要。

https://www.server-memo.net/memo/ssl-cert-san.html

 

なお、systemctl restart nginxとしたときにエラーが出たときは、

https://qiita.com/hnakamur/items/a18eff87a5f0558ae538

のようにログを見た。