Apache 在 FastCGI VirtualHost 上给出 400 错误

发布于 2024-07-09 22:03:00 字数 892 浏览 6 评论 0原文

每当我访问由 FastCGI 脚本处理的页面驱动时,Apache 都会发出 HTTP 响应代码:400“错误请求”,但没有任何详细信息。

  • 我已经安装了 mod_fcgid 模块,并且在 Apache 配置文件中加载和配置了它。
  • 我测试了几个 FastCGI 脚本,所有这些脚本都在直接执行时运行。
  • 静态资源得到适当的服务。
  • Apache 正在尝试启动该脚本,因为当我将 URL 重写为不存在的脚本时它会抱怨

任何人都知道我的 Apache 配置有什么问题吗?

<VirtualHost ip.ad.re.ss:80>
  ServerName   demo.domain.com:80 

  DocumentRoot /var/www/vhosts/domain.com/subdomains/demo/rails/public
  CustomLog  /var/www/vhosts/domain.com/statistics/logs/demo_access_log combined
  ErrorLog  /var/www/vhosts/domain.com/statistics/logs/demo_error_log
  LogLevel info
  Options +FollowSymLinks +ExecCGI -SymLinksIfOwnerMatch
  AddHandler fcgid-script .fcgi

  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
</VirtualHost>

编辑——我已经检查了 mod_rewrite 日志并且 URI 被正确重写

Apache is spitting out a HTTP response of code: 400 "Bad Request" with no details whenever I access a page driven that is handled by a FastCGI script.

  • I've installed the mod_fcgid module and it's loaded and configured in the Apache config files
  • I've tested several FastCGI scripts, all of them run when directly executed.
  • Static resources are served appropriately.
  • Apache is trying to launch the script because it complains when I rewrite the URL to a non-existant script

Anyone have any idea what's wrong with my Apache Config?

<VirtualHost ip.ad.re.ss:80>
  ServerName   demo.domain.com:80 

  DocumentRoot /var/www/vhosts/domain.com/subdomains/demo/rails/public
  CustomLog  /var/www/vhosts/domain.com/statistics/logs/demo_access_log combined
  ErrorLog  /var/www/vhosts/domain.com/statistics/logs/demo_error_log
  LogLevel info
  Options +FollowSymLinks +ExecCGI -SymLinksIfOwnerMatch
  AddHandler fcgid-script .fcgi

  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
</VirtualHost>

EDIT -- I've checked the mod_rewrite logs and URI's are being rewritten correctly

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

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

发布评论

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

评论(2

单调的奢华 2024-07-16 22:03:00

尝试删除 DOCUMENT_ROOT 重写条件。 其次,检查 mod_rewrite 日志指令,它们对于像这样的奇怪问题提供了非常丰富的信息。

Try removing the DOCUMENT_ROOT rewrite cond. Second, checkout the mod_rewrite log directives, they're extremely informative as far as weird issues like this.

一抹苦笑 2024-07-16 22:03:00

好吧,还有一件事要尝试。
http://httpd.apache.org/docs/2.2/mod/ core.html#loglevel

将日志级别设置为调试,并确保这不是在生产计算机上,因为它会为每个单独的事件(获取/放置)生成大量输出。

我认为上面的 FastCGI 示例缺少一些东西,但我承认我已经有一段时间没有做过除了 php 或 python fastcgi 之外的任何事情了。
dispatch.fcgi 使用什么语言?
您可以从命令行执行它吗?Apache 是否有执行该文件的权限? ( sudo su apacheaccount )。

更新:
知道你错过了一些东西:查看 -> http://fastcgi.coremail.cn/configuration.htm FCGIWrapper需要告诉fast cgi使用什么来执行dispatch.fcgi 文件。

Alright, one more thing to try.
http://httpd.apache.org/docs/2.2/mod/core.html#loglevel.

Set the log level to debug and make sure this is not on a production machine because it produces a lot of output per individual event (get/put).

I think how your example above of FastCGI is missing something, but I admit its been a while since I've done anything but php or python fastcgi.
What language is dispatch.fcgi in?
Can you execute it from the command line and does Apache have permission to execute the file? ( sudo su apacheaccount ).

Update:
Knew you were missing something: check out -> http://fastcgi.coremail.cn/configuration.htm FCGIWrapper is needed to tell fast cgi what to use to execute your dispatch.fcgi file.

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