Quando executo uma solicitação cURL no meu servidor apache2 via HTTP, a única resposta que recebo é Invalid Host header
. No entanto, ao usar HTTPS, tudo parece funcionar conforme o esperado. Eu tenho a reescrita habilitada para cada site redirecionar para HTTPS. Isso ocorre em todos os subdomínios. Embora eu tenha feito algumas pesquisas, tudo o que posso encontrar são problemas relacionados ao webpack.
Eu estou apache2 2.4.52
correndo ubuntu 22.04 LTS
.
Aqui está o arquivo conf da minha página principal.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example.com
ServerName example.com
ServerAlias a.example.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Saída decURL --head --verbose http://example.com
* Trying <my-ip>:80...
* Connected to example.com (my-ip) port 80 (#0)
> HEAD / HTTP/1.1
> Host: example.com
> User-Agent: curl/7.84.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
< Connection: Keep-Alive
Connection: Keep-Alive
< Content-Length: 9
Content-Length: 9
< Content-Type: text/plain
Content-Type: text/plain
< Date: Sun, 24 Jul 2022 16:09:03 GMT
Date: Sun, 24 Jul 2022 16:09:03 GMT
<
* Connection #0 to host example.com left intact
Depois de experimentar um pouco. Descobri que era um erro de encaminhamento de porta porque estava resolvendo corretamente localmente, mas não do domínio.