我使用一个可以在 Apache 中发布文件的简单站点:
文件:/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>
这些文件是简单的 XML,示例以以下几行开始:
<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/"
当我在本地下载文件时,wget
抱怨没有标题:
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]
下载的文件开始如下:
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/"
显然,第一行不属于那里,并且阻止正确识别 HTTP 标头。该行来自哪里?我该如何关闭它?我在其他系统上没有遇到过类似情况。
服务器版本:Apache/2.4.41(Ubuntu)
已加载的模块:
core_module(静态)
so_module(静态)
watchdog_module(静态)
http_module(静态)
log_config_module(静态
) logio_module(静态)
version_module(静态)
unixd_module(静态
) access_compat_module(共享)
alias_module(共享)
auth_basic_module
(共享) authn_core_module(共享)
authn_file_module(共享)
authnz_ldap_module
(共享)
authz_core_module(共享) authz_host_module
(共享) authz_user_module(共享)
autoindex_module(共享)
dav_module(共享)
dav_fs_module(共享)
deflate_module(共享)
dir_module(共享)
env_module(共享)
expires_module(共享)
filter_module(共享)
headers_module(共享)
jk_module(共享)
ldap_module(共享)
mime_module(共享)
mpm_prefork_module(共享)
negotiation_module(共享)
php7_module(共享)
reqtimeout_module(共享)
rewrite_module(共享)
setenvif_module(共享)
socache_shmcb_module(共享)
ssl_module(共享)
status_module(共享)
文件:(/etc/apache2/sites-enabled/000-default.conf
评论已删除)
<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>
文件:(/etc/apache2/sites-enabled/default-ssl.conf
评论已删除)
<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>
编辑:输出curl -i
:
user@myhostname:~# curl -i http://myhostname/contents/example/example.xml
curl: (1) Received HTTP/0.9 when not allowed
输出wget -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
(...)
代表 XML 文件内容。我还看到末尾有一些不应该属于那里的内容。我认识到这些内容是通过 JkMount 包含的 Web 应用程序的一部分。最后一行的内容也因每次请求而异。
输出tcpdump -vv -i any -s 0 'tcp port http'
(我希望我得到了正确的行,因为同时有人在服务器上工作):
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
您可以看到最后三个条目恰好在 5 秒后出现,这是底部不相关的内容。
重要补充发现:
Web 文件夹已完全清空,没有 .htaccess 文件可以播放。
如果通过压缩查询 (Accept-Encoding gzip) 检索 XML 文件,则不会发生此行为
如果我从“conf-enabled”中删除“security.conf”,我会得到略有不同(但仍然是错误的)的第一行输出:
st-Modified: Thu, 28 Nov 2024 09:41:43 GMT
[sic!]仅当通过指向 CIFS 挂载点的 Web 文件夹中的符号链接下载 XML 文件时才会发生此行为,而当 XML 文件位于文件夹中时则不会发生此行为