AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 783863
Accepted
ychaouche
ychaouche
Asked: 2016-06-15 05:33:14 +0800 CST2016-06-15 05:33:14 +0800 CST 2016-06-15 05:33:14 +0800 CST

使用 mod_proxy[_html] 时出现许多 404 URL

  • 772

我想做的事

使所有http://cloud.example.com/显示为http://webmail.example.com/cloud/

  • http://cloud.example.com:目标网站
  • http://webmail.example.com:使用 mod_proxy 运行 apache2 的网站,作为反向代理(但不仅限于,还有 webmail)。
  • http://webmail.example.com/cloud:我希望http://cloud.example.com出现的 URL。

我是如何尝试做到的

<VirtualHost  *:80>

  ServerName webmail.example.com
  DocumentRoot /var/www/roundcubemail-1.1.4
  Loglevel debug
  ErrorLog /var/log/apache2/roundcube.error
  # %t  : Time 
  # %a  : client ip 
  # %f  : filename
  # %T  : processing time 
  # %s  : status
  # %>s : Final status
  LogFormat "%t %a %{Referer}i -> %U%q, matches %f, %s>%>s(served in %{ms}T µs)" custom
  # was "combined"
  CustomLog /var/log/apache2/roundcube.access custom     

  ProxyPass  "/cloud/" "http://cloud.example.com/"
  ProxyPassReverse "/cloud/" "http://cloud.example.com/"

  # The ProxyRequests directive should usually be set off when using ProxyPass.
  # src:https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass
  ProxyRequests off

  # https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypreservehost  
  # This option should normally be turned Off.
  ProxyPreserveHost off

</VirtualHost>

日志

[14/Jun/2016:13:42:37 +0100] 192.168.211.202 - -> /cloud/, matches proxy:http://cloud.example.com/, 200>200(served in 5 µs)
[14/Jun/2016:13:42:42 +0100] 192.168.211.202 - -> /core/css/styles.css?v=9a1b1350ff46cbc098bc6c7acca55c1c, matches /var/www/roundcubemail-1.1.4/core, 404>404(served in 0 µs)
[14/Jun/2016:13:42:42 +0100] 192.168.211.202 - -> /core/css/header.css?v=9a1b1350ff46cbc098bc6c7acca55c1c, matches /var/www/roundcubemail-1.1.4/core, 404>404(served in 0 µs)
[14/Jun/2016:13:42:42 +0100] 192.168.211.202 - -> /core/css/mobile.css?v=9a1b1350ff46cbc098bc6c7acca55c1c, matches /var/www/roundcubemail-1.1.4/core, 404>404(served in 0 µs)
[14/Jun/2016:13:42:42 +0100] 192.168.211.202 - -> /core/css/icons.css?v=9a1b1350ff46cbc098bc6c7acca55c1c, matches /var/www/roundcubemail-1.1.4/core, 404>404(served in 0 µs)
[14/Jun/2016:13:42:42 +0100] 192.168.211.202 - -> /core/css/fonts.css?v=9a1b1350ff46cbc098bc6c7acca55c1c, matches /var/www/roundcubemail-1.1.4/core, 404>404(served in 0 µs)
[14/Jun/2016:13:42:42 +0100] 192.168.211.202 - -> /core/css/apps.css?v=9a1b1350ff46cbc098bc6c7acca55c1c, matches /var/www/roundcubemail-1.1.4/core, 404>404(served in 0 µs)
...

日志的第一行显示请求“/cloud/”路径成功从代理网站检索资源,但所有后续资源都不是从云服务器获取,而是从网络邮件服务器本身获取。

How can I take care of this ?

I have proxy_html enabled.

root@messagerie[CHROOT][10.10.10.20] ~ # a2query -m
proxy (enabled by site administrator)
php5 (enabled by maintainer script)
setenvif (enabled by maintainer script)
ssl (enabled by site administrator)
deflate (enabled by maintainer script)
authn_core (enabled by maintainer script)
env (enabled by maintainer script)
mime (enabled by maintainer script)
auth_basic (enabled by maintainer script)
access_compat (enabled by maintainer script)
authz_core (enabled by maintainer script)
xml2enc (enabled by site administrator)
authz_host (enabled by maintainer script)
alias (enabled by maintainer script)
authz_user (enabled by maintainer script)
autoindex (enabled by maintainer script)
negotiation (enabled by maintainer script)
socache_shmcb (enabled by site administrator)
proxy_http (enabled by site administrator)
status (enabled by maintainer script)
proxy_html (enabled by site administrator)
filter (enabled by maintainer script)
authn_file (enabled by maintainer script)
dir (enabled by maintainer script)
mpm_prefork (enabled by maintainer script)
root@messagerie[CHROOT][10.10.10.20] ~ # 
httpd mod-proxy apache-2.4
  • 1 1 个回答
  • 1998 Views

1 个回答

  • Voted
  1. Best Answer
    ychaouche
    2016-06-16T04:13:52+08:002016-06-16T04:13:52+08:00

    As suggested by @HBruijn I've added

      ProxyPass "/core/" "http://cloud.algerian-radio.dz/core/"
      ProxyPassReverse "/core/" "http://cloud.algerian-radio.dz/core/"
    

    But then the server received requests for /index.php/apps/files/, so I added that as well

      ProxyPass  "/index.php/apps/files/" "http://cloud.algerian-radio.dz/apps/file\
    s/"
      ProxyPassReverse "/index.php/apps/files/" "http://cloud.algerian-radio.dz/app\
    s/files/"
    

    Got rid of all the 404 errors, but couldn't get owncloud to work nevertheless.

    http://webmail.example.com/cloud redirects to http://webmail.example.com/index.php/apps/files/ which displays this nice error :

    Fatal error: Class 'OCP\User' not found in /usr/local/nginx/html/owncloud/apps/files/index.php on line 33
    

    EDIT : fixed !, some additional configuration was needed on owncloud's part, namely trusted_proxies and overwritewebroot.

    • 0

相关问题

  • 当 httpd 被赋予错误的端口号时会发生什么?

  • Apache httpd 集群日志记录

  • HTTP -> HTTPS 重定向与 OpenBSD 的 httpd [关闭]

  • PHP 网络服务器的最快选择

  • 什么会导致 Apache HTTPD 无限期地使用 100% CPU

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve