感謝各位前輩幫忙提供意見,我今日又把所有流程都測試過一遍,這次讓我真的學到超多,因為我主要是全端開發,這實在蠻陌生的領域。
我發現原來是路由器(?)那邊沒有設定到,因為我是真的對網路這塊非常不熟哈哈哈...
在這邊幫443新增就可以了,成功的時候我差點吐血,體會到知識不足的可怕。
另外因為我是在購買憑證的時候,直接用Godaddy的工具(新購買會送一次)生成csr跟key,
後來找資料無意中翻到,原來他給的檔案不是PEM的格式,要自己轉,神奇的是,在我轉換成PEM之前,完全沒有報錯,也算一個坑吧?
如果有路過的邦友有類似的狀況,可以私訊我,也許我能幫上忙。
------------------更新線----------------
各位前輩好,近日在幫公司的伺服器安裝SSL憑證,是購買godaddy的憑證自己安裝,已經照了網上大部分教學的步驟去設定,設定一輪過後,重新啟動apache也沒有錯誤,LOG也沒有,http仍然可以用,https就是不行...
DNS是採用godaddy的 那邊都沒有動過
已經有啟用以下幾個設定
sudo a2enmod ssl
sudo a2enmod headers
需要更多資訊我可以提供!
請幫我看看是不是哪邊做錯了~ 謝謝各位!!!
以下是/etc/apache2/sites-available/000-default.conf的內容
域名我先用yxxxx.co做替代
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName yxxxx.co
ServerAlias www.yxxxx.co
SSLProtocol All -SSLv2 -SSLv3
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/5a4af56c90eb1ce.crt
SSLCertificateKeyFile /etc/apache2/ssl/generated-private-key.key
SSLCertificateChainFile /etc/apache2/ssl/gd_bundle-g2-g1.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName yxxxx.co
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
以下是/etc/apache2/ports.conf的內容
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
以下是/etc/apache2/apache2.conf的內容
為方便看我刪掉一些註解
DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
SSLCertificateFile /etc/apache2/ssl/5a4af56c90eb1ce.crt
SSLCertificateKeyFile /etc/apache2/ssl/generated-private-key.key
LogLevel warn
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride ALL
Require all granted
Header add Access-Control-Allow-Origin *
Header set Cache-Control "max-age=36000, public"
<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
</IfModule>
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
以下是netstat -an | grep :443的結果
tcp6 0 0 :::443 :::* LISTEN
以下是apachectl -S的結果
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:443 yxxxx.co (/etc/apache2/sites-enabled/000-default.conf:1)
*:80 yxxxx.co (/etc/apache2/sites-enabled/000-default.conf:24)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used