
Debian에 Apache 2.4가 있고 두 개의 VirtualHost를 구성했습니다.
- 첫 번째는 모든 "보안되지 않은" 요청을 보안 VirtualHost로 전달하기 위해 포트 80을 수신하는 것입니다.
- 두 번째는 "보안" VirtualHost이며 포트 443을 수신하는 것입니다.
참고: 저는 텍스트에 "example.com"을 사용하지만 SSL을 사용하는 가짜가 아닌 도메인을 가지고 있습니다 :-)
연결을 테스트할 때 https://example.com
오류가 발생합니다.
"오류:1408F10B:SSL 루틴:ssl3_get_record:잘못된 버전 번호" 클라이언트 측에서곱슬 곱슬하다/ "ERR_SSL_PROTOCOL_ERROR" 와 함께크롬
"AH00566: 요청 실패: 잘못된 요청 라인"Apache 서버 측에서
포트 443으로 연결을 테스트할 때도 https://example.com:443
동일한 오류가 발생합니다.
(프로토콜 http 및 포트 443) 에 대한 연결을 테스트하면 http://example.com:443
Apache의 기본 인덱스 페이지가 성공적으로 표시됩니다. .... 이것은 내가 실제로 기대했던 내 자신의 index.html은 아니지만. 그러나 이는 나중의 또 다른 문제이다.
지난번 테스트 성공 이후로 SSL 인증서에는 문제가 없는 것으로 추측됩니다. 그렇죠?
두 포트 모두에서 수신 대기하는 Apache 솔기:
> sudo apache2ctl -S
VirtualHost configuration:
*:80 example.com (/etc/apache2/sites-enabled/example.com.conf:10)
*:433 example.com (/etc/apache2/sites-enabled/example.com.conf:21)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
> netstat -tupln
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
udp 0 0 0.0.0.0:68 0.0.0.0:* -
udp6 0 0 fe80::250:56ff:fe20:546 :::*
내 "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 0.0.0.0:80
<IfModule ssl_module>
Listen 0.0.0.0:443
</IfModule>
<IfModule mod_gnutls.c>
Listen 0.0.0.0:443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
사이트가 활성화된 내 "example.com.conf":
########
# main config file for my webpage
########
# NameVirtualHost is deprected
#NameVirtualHost *:443
<VirtualHost *:80>
ServerName example.de
# this line is masked for superuser.com due to privacy
ServerAlias XXXXXXX.online-server.cloud www.example.com xxx.xxx.xx.xx
Redirect permanent / https://example.com
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/example-nossl-access.log combined
ErrorLog ${APACHE_LOG_DIR}/example-nossl-error.log
</VirtualHost>
# Default-Host
<VirtualHost *:433>
# admin mail given to user when any issues occur
ServerAdmin [email protected]
# the domain that routes to DocumentRoot
ServerName example.com
# alias which also routes to DocumentRoot
# this line is masked for superuser.com due to privacy
ServerAlias www.example.com XXXXXX.online-server.cloud xxx.xxx.xx.xx
DocumentRoot /var/www/example-homepage
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/example-access.log combined
ErrorLog ${APACHE_LOG_DIR}/example-error.log
#<IfModule mod_ssl.c>
SSLEngine on
SSLCertificateKeyFile /etc/apache2/ssl/_.example.com_private_key.key
SSLCertificateFile /etc/apache2/ssl/example.com_ssl_certificate.cer
#</IfModule>
</VirtualHost>
<Directory /var/www/example-homepage>
# allow .htaccess files in root directory
AllowOverride All
</Directory>
편집하다SSL 로그:
[Fri Feb 07 07:17:37.546729 2020] [ssl:info] [pid 83145:tid 139622694843520] AH01914: Configuring server example.com:443 for SSL protocol
[Fri Feb 07 07:17:37.546735 2020] [ssl:debug] [pid 83145:tid 139622694843520] ssl_engine_init.c(1750): AH10083: Init: (example.com:443) mod_md support is unavailable.
[Fri Feb 07 07:17:37.546943 2020] [ssl:debug] [pid 83145:tid 139622694843520] ssl_engine_init.c(479): AH01893: Configuring TLS extension handling
[Fri Feb 07 07:17:37.547220 2020] [ssl:debug] [pid 83145:tid 139622694843520] ssl_util_ssl.c(476): AH02412: [example.com:443] Cert matches for name 'example.com' [subject: CN=*.example.com / issuer: CN=Encryption Everywhere DV TLS CA - G1,OU=www.digicert.com,O=DigiCert Inc,C=US / serial: 0C9227F96F2A0EFA7B7E6F7391B9EBA0 / notbefore: Dec 26 00:00:00 2019 GMT / notafter: Dec 25 12:00:00 2020 GMT]
[Fri Feb 07 07:17:37.547229 2020] [ssl:info] [pid 83145:tid 139622694843520] AH02568: Certificate and private key example.com:443:0 configured from /etc/apache2/ssl/example.com_ssl_certificate.cer and /etc/apache2/ssl/_.example.com_private_key.key
편집 2컬의 자세한 로그:
* Expire in 0 ms for 6 (transfer 0x55ac2933ef50)
* Expire in 1 ms for 1 (transfer 0x55ac2933ef50)
...
* Trying xxx.xxx.xx.xx...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x55ac2933ef50)
* Connected to example.com (xxx.xxx.xx.xx) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* error:1408F10B:SSL routines:ssl3_get_record:wrong version number
* Closing connection 0
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
https가 아닌 이유를 이해하도록 도와주세요.매핑된포트 443으로 연결하고 해당 문제를 해결하여 https://example.com
.
답변1
내 멍청한 오타였어example.com.conf. 포트 4를 바꿔야 했어요334까지43:
...
# Default-Host
<VirtualHost *:433>
...
에게
...
# Default-Host
<VirtualHost *:443>
...
이제 작동합니다.
답변2
제 경우에는 구성이 잘못된 것으로 나타났습니다. 하나의 가상 호스트 구성 파일에는 두 섹션이 모두 있습니다
<VirtualHost *:80>
...
</VirtualHost>
<VirtualHost *:443>
...
</VirtualHost>
다른 파일에는 가 있었는데 <VirtualHost *:443>
이 파일은 다른 파일의 잘못된 구성으로 인해 작동하지 않았습니다. 포트 443의 서버는 TLS와 전혀 통신하지 않았으며 HTTP 요청에 올바르게 응답했습니다.
그럼에도 불구하고 서버가 실행되고 오류가 보고되지 않았음에도 불구하고 근본 원인을 찾는 데 정말 어려움을 겪었습니다.