MediaWiki - 404 的 HTML 内容之前有四个垃圾字符

发布于 2024-12-07 22:12:18 字数 3048 浏览 1 评论 0原文

所以我刚刚第一次安装 MediaWiki,并且遇到了一个奇怪的问题,我找不到解决方案。在过去的几个小时里,我一直在爬行帮助文档、搜索谷歌并阅读文章,但找不到答案。

一切工作正常,除了在 404 页面上,在 HTML 之前输出了四个垃圾字符。所有其他页面看起来都很好,只有 404 页面。它们每一个都不同,在我看来是十六进制的,我见过数字,没有高于 f 的字母。

示例

我已经重新安装了两次,每次都遇到同样的问题。

系统设置

  • Centos 5.6
  • Apache 2.2.3 运行 nginx (0.8.55) 反向代理
  • PHP 5.3.2
  • MySQL 5.0.77

服务器配置

Apache

<VirtualHost 127.0.0.1:8080>
    DocumentRoot /home/sites/oneltd.co.uk/wiki
    ServerName wiki.oneltd.co.uk
    Alias /wiki /home/sites/oneltd.co.uk/wiki/index.php
    <Directory "/home/sites/oneltd.co.uk/wiki">
            Allowoverride all
    </Directory>
    CustomLog /home/sites/oneltd.co.uk/_logs/access_log "combined"
    ErrorLog /home/sites/oneltd.co.uk/_logs/error_log
</VirtualHost>

nginx

server {
    listen 205.186.146.37:80;
    server_name wiki.oneltd.co.uk;
    server_name_in_redirect off;

    access_log /home/sites/oneltd.co.uk/_logs/nginx.access_log;

    location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }


    location ~ \.(jpg|jpeg|png|gif|swf|flv|mp4|mov|avi|wmv|m4v|mkv|ico|js|css|txt|html|htm)$ {
            root /home/sites/oneltd.co.uk/wiki;
            gzip on;
            gzip_comp_level 2;
            gzip_vary on;
            gzip_proxied any;
            gzip_types text/plain text/xml text/css application/x-javascript;
            expires max;
    }
}

的任何帮助或想法非常感谢在哪里查看:)

编辑 - 问题已修复!

感谢 Greg Hewgill 关于分块编码的回复,我设法找到了 问题。事实证明,nginx 在作为反向代理工作时无法与 HTTP/1.1 通信,但您可以强制 Apache 降级到 1.0。 后,我找到了答案:

在阅读Drupal的类似问题更新的Apache配置

<VirtualHost 127.0.0.1:8080>
    DocumentRoot /home/sites/oneltd.co.uk/wiki
    ServerName wiki.oneltd.co.uk
    Alias /wiki /home/sites/oneltd.co.uk/wiki/index.php
    <Directory "/home/sites/oneltd.co.uk/wiki">
            Allowoverride all
    </Directory>
    CustomLog /home/sites/oneltd.co.uk/_logs/access_log "combined"
    ErrorLog /home/sites/oneltd.co.uk/_logs/error_log


    # nginx can't deal with HTTP/1.1 at the moment, force downgrade to 1.0
    SetEnv force-response-1.0 1
    SetEnv downgrade-1.0 1
</VirtualHost>

So I've just installed MediaWiki for the first time and am having a weird problem which I can't find a solution to. I have been crawling the help docs, searching Google and reading articles for the last couple of hours and can't find an answer.

Everything is working fine, except on a 404 page, four garbage characters are output before the HTML. All other pages appear to be fine, just the 404s. They are different on each one and look to me to be in hex, I've seen numbers and no letter higher than an f.

Examples

I have reinstalled it twice with the same problem each time.

System setup

  • Centos 5.6
  • Apache 2.2.3 running with an nginx (0.8.55) reverse proxy
  • PHP 5.3.2
  • MySQL 5.0.77

Server configs

Apache

<VirtualHost 127.0.0.1:8080>
    DocumentRoot /home/sites/oneltd.co.uk/wiki
    ServerName wiki.oneltd.co.uk
    Alias /wiki /home/sites/oneltd.co.uk/wiki/index.php
    <Directory "/home/sites/oneltd.co.uk/wiki">
            Allowoverride all
    </Directory>
    CustomLog /home/sites/oneltd.co.uk/_logs/access_log "combined"
    ErrorLog /home/sites/oneltd.co.uk/_logs/error_log
</VirtualHost>

nginx

server {
    listen 205.186.146.37:80;
    server_name wiki.oneltd.co.uk;
    server_name_in_redirect off;

    access_log /home/sites/oneltd.co.uk/_logs/nginx.access_log;

    location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }


    location ~ \.(jpg|jpeg|png|gif|swf|flv|mp4|mov|avi|wmv|m4v|mkv|ico|js|css|txt|html|htm)$ {
            root /home/sites/oneltd.co.uk/wiki;
            gzip on;
            gzip_comp_level 2;
            gzip_vary on;
            gzip_proxied any;
            gzip_types text/plain text/xml text/css application/x-javascript;
            expires max;
    }
}

Any help or ideas of where to look will be greatly appreciated :)

EDIT - PROBLEM FIXED!

Thanks to Greg Hewgill's response about the chunked encoding, I managed to find the problem. It turns out that nginx can't talk HTTP/1.1 when working as a reverse proxy, but you can force Apache to downgrade to 1.0. I found the answer after reading about a similar problem with Drupal

Updated Apache config:

<VirtualHost 127.0.0.1:8080>
    DocumentRoot /home/sites/oneltd.co.uk/wiki
    ServerName wiki.oneltd.co.uk
    Alias /wiki /home/sites/oneltd.co.uk/wiki/index.php
    <Directory "/home/sites/oneltd.co.uk/wiki">
            Allowoverride all
    </Directory>
    CustomLog /home/sites/oneltd.co.uk/_logs/access_log "combined"
    ErrorLog /home/sites/oneltd.co.uk/_logs/error_log


    # nginx can't deal with HTTP/1.1 at the moment, force downgrade to 1.0
    SetEnv force-response-1.0 1
    SetEnv downgrade-1.0 1
</VirtualHost>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮色兮凉城 2024-12-14 22:12:18

这听起来可能与 HTTP 分块传输编码有关。对于分块传输,每个块的长度在实际内容之前以十六进制形式发送。

我不知道为什么这会成为您安装中的问题,也不知道如何修复它,但在搜索解决方案时它可能是有用的信息。

This sounds like it might be somehow related to HTTP chunked transfer encoding. With chunked transfer, the length of each chunk is sent in hex before the actual content.

I don't know why this would be a problem in your install, or how to fix it, but it might be useful information when searching for a solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文