Apache HTTPD Centos 7错误请求

Apache HTTPD Centos 7错误请求,apache,.htaccess,ssl,httpd.conf,Apache,.htaccess,Ssl,Httpd.conf,嗯,我有一个奇怪的问题,这是第一次, OS:Centos 7 Apache: Server version: Apache / 2.4.6 (CentOS) Server built: Aug 5 2020 16:41:29 我的问题如下: 我在httpd.cnf配置文件中没有重定向,在主机文件中也没有重定向。htaccess无法重定向到https 所有http请求返回错误: <! DOCTYPE HTML PUBLIC "- // IETF // DTD HTML 2.0 /

嗯,我有一个奇怪的问题,这是第一次,
OS:Centos 7
Apache:

Server version: Apache / 2.4.6 (CentOS)
Server built: Aug 5 2020 16:41:29
我的问题如下: 我在httpd.cnf配置文件中没有重定向,在主机文件中也没有重定向。htaccess无法重定向到https

所有http请求返回错误:

<! DOCTYPE HTML PUBLIC "- // IETF // DTD HTML 2.0 // EN">
<html> <head>
<title> 400 Bad Request </title>
</head> <body>
<h1> Bad Request </h1>
<p> Your browser sent a request that this server could not understand. <br />
Reason: You're speaking plain HTTP to an SSL-enabled server port. <br />
  Instead use the HTTPS scheme to access this URL, please. <br />
</p>
</body> </html>
2-其他解决方案:

<VirtualHost example.com:80>
SuexecUserGroup "#1008" "#1008"
ServerName example.com
ServerAlias www.example.com
DocumentRoot /directory/html
...
</VirtualHost>

<VirtualHost example.com:443>
SuexecUserGroup "#1008" "#1008"
ServerName example.com
ServerAlias www.example.com
DocumentRoot /directory/html
SSLEngine On
...
</VirtualHost>
因此,无论是否使用这种配置,服务器都可以在https和http返回错误请求的情况下正常工作

带卷曲:

# curl -sD  - http://jelocalise.maroccrm.com

HTTP/1.1 400 Bad Request
Date: Fri, 30 Oct 2020 13:32:40 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.6.40
Content-Length: 362
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
 Instead use the HTTPS scheme to access this URL, please.<br />
</p>
</body></html>
#curl-sD-http://jelocalise.maroccrm.com
HTTP/1.1400错误请求
日期:2020年10月30日星期五13:32:40 GMT
服务器:Apache/2.4.6(CentOS)OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.6.40
内容长度:362
连接:关闭
内容类型:text/html;字符集=iso-8859-1
400错误请求
错误的请求
您的浏览器发送了此服务器无法理解的请求。
原因:您正在对启用SSL的服务器端口使用普通HTTP。
请改用HTTPS方案访问此URL。

对不起,我的英语不好

原因:您正在对启用SSL的服务器端口使用普通HTTP。

您在端口80上配置了HTTPS,该端口通常用于普通HTTP。这就是以下成功的原因:

$ curl -k  https://jelocalise.maroccrm.com:80
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Dolibarr Development Team">
....
$curl-khttps://jelocalise.maroccrm.com:80
....

很可能在您的配置中的某个地方(您只显示了一部分)有为端口80或某个VirtualHost全局配置的SSLEngine。

共享有问题的错误日志。您是正确的。谢谢,我的一个VirtualHost有这样的声明:在SSLEngine On内,所以我复制了配置并删除了SSLEngine inside:80,现在可以工作了,谢谢。
# curl -sD  - http://jelocalise.maroccrm.com

HTTP/1.1 400 Bad Request
Date: Fri, 30 Oct 2020 13:32:40 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.6.40
Content-Length: 362
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
 Instead use the HTTPS scheme to access this URL, please.<br />
</p>
</body></html>
$ curl -k  https://jelocalise.maroccrm.com:80
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Dolibarr Development Team">
....