【備忘録】MAMPでVirtualHost+SSL(オレオレ証明書)

MAMP-logo 技術

前回の続き

SSLの有効化

/Applications/MAMP/conf/apache/httpd.conf

Include行をコメントアウト

# Secure (SSL/TLS) connections
Include /Applications/MAMP/conf/apache/extra/httpd-ssl.conf

/Applications/MAMP/conf/apache/extra/httpd-ssl.conf

以下のように書き換え

##
## SSL Virtual Host Context
##
<VirtualHost _default_:443>
...
</VirtualHost>
##
## SSL Virtual Host Context
##

NameVirtualHost *:443
<VirtualHost *:443>
    SSLEngine on
	DocumentRoot "/Applications/MAMP/htdocs/"
	ServerName localhost:443
	
	SSLCertificateFile /Applications/MAMP/conf/apache/myssl/localhost.pem
	SSLCertificateKeyFile /Applications/MAMP/conf/apache/myssl/localhost-key.pem
</VirtualHost>
<VirtualHost *:443>
    SSLEngine on
	DocumentRoot "/Applications/MAMP/htdocs/sanrioho.st"
	ServerName sanrioho.st.local:443
	
	SSLCertificateFile /Applications/MAMP/conf/apache/myssl/sanrioho.st.local.pem
	SSLCertificateKeyFile /Applications/MAMP/conf/apache/myssl/sanrioho.st.local-key.pem
</VirtualHost>

あとはapacheを再起動

※SSLCertificateFile, SSLCertificateKeyFile はこちらの記事を元に作成しました

% brew install mkcert
% mkcert -install

% cd /Applications/MAMP/conf/apache/myssl/
% mkcert localhost
% mkcert sanrioho.st.local
% ls
localhost-key.pem             sanrioho.st.local-key.pem
localhost.pem                 sanrioho.st.local.pem

コメント

タイトルとURLをコピーしました