Eu uso um site simples habilitado para publicar arquivos no Apache:
Arquivo:/etc/apache2/sites-enabled/contents.conf
<Directory "/mnt/data/contents/">
Options FollowSymLinks
Require all granted
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 7 days"
</IfModule>
</Directory>
Os arquivos são XML simples, um exemplo começa com estas linhas:
<mets:mets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:kitodo="http://meta.kitodo.org/v1/"
Quando baixo o arquivo localmente, wget
ele reclama da falta de cabeçalhos :
user@myhostname:~$ wget http://myhostname/contents/example/example.xml
--2024-12-05 16:14:59-- http://myhostname/contents/example/example.xml
Resolving myhostname (myhostname)... 127.0.1.1
Connecting to myhostname (myhostname)|127.0.1.1|:80... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: ‘example.xml’
example.xml [ <=> ] 12,66K --.-KB/s in 4,8s
2024-12-05 16:15:04 (2,66 KB/s) - ‘example.xml’ saved [12966]
O arquivo baixado começa assim:
12:25:45 GMT
Accept-Ranges: bytes
Content-Length: 12563
Cache-Control: max-age=0
Expires: Thu, 05 Dec 2024 09:45:44 GMT
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/xml; charset=utf-8
<mets:mets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:kitodo="http://meta.kitodo.org/v1/"
Obviamente a primeira linha não pertence ali e impede que os cabeçalhos HTTP sejam reconhecidos corretamente. De onde vem a linha e como posso desligá-la? Não experimento nada parecido com isso em outros sistemas.
Versão do servidor: Apache/2.4.41 (Ubuntu)
Módulos carregados:
core_module (estático)
so_module (estático)
watchdog_module (estático)
http_module (estático)
log_config_module (estático)
logio_module (estático)
version_module (estático)
unixd_module (estático
) access_compat_module (compartilhado
) alias_module (compartilhado)
auth_basic_module (compartilhado
) authn_core_module (compartilhado)
authn_file_module (compartilhado)
authnz_ldap_module
(compartilhado)
authz_core_module (compartilhado) authz_host_module
(compartilhado) authz_user_module (compartilhado)
autoindex_module (compartilhado)
dav_module (compartilhado)
dav_fs_module (compartilhado)
deflate_module (compartilhado)
dir_module (compartilhado)
env_module (compartilhado)
expires_module (compartilhado)
filter_module (compartilhado
) headers_module (
compartilhado) jk_module (
compartilhado) ldap_module (compartilhado
) mime_module (compartilhado
) mpm_prefork_module (compartilhado)
negotiation_module (compartilhado)
php7_module (compartilhado)
reqtimeout_module (compartilhado)
rewrite_module (compartilhado)
setenvif_module (compartilhado)
socache_shmcb_module (compartilhado)
ssl_module (compartilhado)
status_module (compartilhado)
Arquivo: /etc/apache2/sites-enabled/000-default.conf
(comentários removidos)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/typo3/public
<Directory /var/www/typo3/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
JkMount /kitodo ajp13_worker
JkMount /kitodo/* ajp13_worker
<Location /kitodo>
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Arquivo: /etc/apache2/sites-enabled/default-ssl.conf
(comentários removidos)
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
Editar: Saída de curl -i
:
user@myhostname:~# curl -i http://myhostname/contents/example/example.xml
curl: (1) Received HTTP/0.9 when not allowed
Saída dewget -O - -o /dev/null --save-headers
09:41:43 GMT
Accept-Ranges: bytes
Content-Length: 10971
Cache-Control: max-age=0
Expires: Mon, 09 Dec 2024 08:22:33 GMT
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/xml; charset=utf-8
(...)
ataTable:11:inputText",onco:function(xhr,status,args,data){preserveMetadata(); updateTitleMetadata();;}});" /><s
(...)
representa o conteúdo do arquivo XML. Também vejo que há conteúdo no final que também não deveria estar ali. Reconheço esse conteúdo como parte do aplicativo da web incluído por meio do JkMount. E o conteúdo na última linha também é diferente a cada solicitação.
Saída de tcpdump -vv -i any -s 0 'tcp port http'
(espero ter escrito as falas certas, porque há pessoas trabalhando no servidor enquanto isso):
09:15:05.940645 IP (tos 0x0, ttl 64, id 26047, offset 0, flags [DF], proto TCP (6), length 60)
localhost.60850 > myhostname.http: Flags [S], cksum 0xff30 (incorrect -> 0x75f8), seq 4023966924, win 65495, options [mss 65495,sackOK,TS val 2467400527 ecr 0,nop,wscale 7], length 0
09:15:05.940660 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
myhostname.http > localhost.60850: Flags [S.], cksum 0xff30 (incorrect -> 0xbe63), seq 1059986559, ack 4023966925, win 65483, options [mss 65495,sackOK,TS val 1084365632 ecr 2467400527,nop,wscale 7], length 0
09:15:05.940673 IP (tos 0x0, ttl 64, id 26048, offset 0, flags [DF], proto TCP (6), length 52)
localhost.60850 > myhostname.http: Flags [.], cksum 0xff28 (incorrect -> 0xe51f), seq 1, ack 1, win 512, options [nop,nop,TS val 2467400527 ecr 1084365632], length 0
09:15:05.940703 IP (tos 0x0, ttl 64, id 26049, offset 0, flags [DF], proto TCP (6), length 241)
localhost.60850 > myhostname.http: Flags [P.], cksum 0xffe5 (incorrect -> 0x771f), seq 1:190, ack 1, win 512, options [nop,nop,TS val 2467400527 ecr 1084365632], length 189: HTTP, length: 189
GET /contents/example/example.xml HTTP/1.1
User-Agent: Wget/1.20.3 (linux-gnu)
Accept: */*
Accept-Encoding: identity
Host: myhostname
Connection: Keep-Alive
09:15:05.940721 IP (tos 0x0, ttl 64, id 2993, offset 0, flags [DF], proto TCP (6), length 52)
myhostname.http > localhost.60850: Flags [.], cksum 0xff28 (incorrect -> 0xe463), seq 1, ack 190, win 511, options [nop,nop,TS val 1084365632 ecr 2467400527], length 0
09:15:05.946161 IP (tos 0x0, ttl 64, id 2994, offset 0, flags [DF], proto TCP (6), length 11426)
myhostname.http > localhost.60850: Flags [P.], cksum 0x2b97 (incorrect -> 0xe10f), seq 1:11375, ack 190, win 512, options [nop,nop,TS val 1084365637 ecr 2467400527], length 11374: HTTP
09:15:05.946180 IP (tos 0x0, ttl 64, id 26050, offset 0, flags [DF], proto TCP (6), length 52)
localhost.60850 > myhostname.http: Flags [.], cksum 0xff28 (incorrect -> 0xb81b), seq 190, ack 11375, win 463, options [nop,nop,TS val 2467400532 ecr 1084365637], length 0
09:15:10.951973 IP (tos 0x0, ttl 64, id 2995, offset 0, flags [DF], proto TCP (6), length 52)
myhostname.http > localhost.60850: Flags [F.], cksum 0xff28 (incorrect -> 0xa45b), seq 11375, ack 190, win 512, options [nop,nop,TS val 1084370643 ecr 2467400532], length 0
09:15:10.952765 IP (tos 0x0, ttl 64, id 26051, offset 0, flags [DF], proto TCP (6), length 52)
localhost.60850 > myhostname.http: Flags [F.], cksum 0xff28 (incorrect -> 0x90cb), seq 190, ack 11376, win 512, options [nop,nop,TS val 2467405539 ecr 1084370643], length 0
09:15:10.952792 IP (tos 0x0, ttl 64, id 2996, offset 0, flags [DF], proto TCP (6), length 52)
myhostname.http > localhost.60850: Flags [.], cksum 0xff28 (incorrect -> 0x90ca), seq 11376, ack 191, win 512, options [nop,nop,TS val 1084370644 ecr 2467405539], length 0
Você pode ver que as três últimas entradas aparecem exatamente 5 segundos depois, o que é o material não relacionado na parte inferior.
Descobertas adicionais importantes:
Pasta da Web completamente esvaziada, nenhum arquivo .htaccess pode ser reproduzido nela.
O comportamento não ocorre se o arquivo XML for recuperado por meio de uma consulta compactada (Accept-Encoding gzip)
Se eu remover 'security.conf' de 'conf-enabled', obtenho uma primeira linha de saída ligeiramente diferente (mas ainda errada):
st-Modified: Thu, 28 Nov 2024 09:41:43 GMT
[sic!]O comportamento só ocorre se o arquivo XML for baixado por meio de um link simbólico na pasta da web que aponta para um ponto de montagem CIFS, não se ele estiver localizado diretamente na pasta