【问题标题】:Apache Apache/2.4.7 (Ubuntu) ProxyPassApache Apache/2.4.7 (Ubuntu) ProxyPass
【发布时间】:2015-10-15 06:03:30
【问题描述】:

我正在尝试使用链接在 /etc/apache2/sites-enable 表单 sites-avalable 中的这个文件(尽可能简单)配置一个简单的 ProxyPass(同一个文件似乎在 apache 2.2 上工作,但可能我已经完成了以前安装的其他配置,我不记得那些配置) 请注意,我使用的是 IPADDRESS 而不是服务器名称,但我认为这不是问题。 注 2:我不是 apache 网络服务器专家 :)!

ServerName IP_SERVER_ADDRESS

# Redmine
ProxyPass        /redmine   http://IP_SERVER_ADDRESS:8555/redmine

# test1
ProxyPass        "/test1"   "http://IP_SERVER_ADDRESS:9180/test1/"
ProxyPassReverse "/test1"   "http://IP_SERVER_ADDRESS:9180/test1/"

# test2
ProxyPass        /test2   http://IP_SERVER_ADDRESS:8880/test2
ProxyPassReverse /test2   http://IP_SERVER_ADDRESS:8880/test2

DocumentRoot /var/www

但它没有工作,所以网址

http://IP_SERVER_ADDRESS:8880/test2

工作正常,但代理网址

http://IP_SERVER_ADDRESS/test2

没用,报错

Not Found

The requested URL /redmine was not found on this server

apache2ctl -S 的输出看起来很奇怪,因为显然没有使用 VirtualHost 配置 (?)

VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex proxy: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

很确定我错过了一些简单的东西,但我找不到!

【问题讨论】:

    标签: apache reverse-proxy apache2.4


    【解决方案1】:

    此答案在 Apache Apache/2.4.7 (Debian) ProxyPass 中进行了测试。

    参见/etc/apache2/apache2.conf:

    # Include the virtual host configurations:
    IncludeOptional sites-enabled/*.conf
    

    以前的版本是

    # Include the virtual host configurations:
    Include sites-enabled/
    

    所以基本上在 apache 2.4(Debian 及其衍生版本)中,您必须使用带有 .conf 扩展名的文件来限制头痛...... 在 Apache 2.2 中,不需要文件名中的 .conf 扩展名。

    其他细节:

    1. 在启用站点的配置文件中(指向可用站点的软链接)必须具有扩展名 .conf 以便 WHATEVER_YOU_WANT。conf
    2. 您必须使用 a2ensite 来启用配置,因为如果 sites-available 中的文件没有“正确”扩展名“.conf”,则会显示“错误:站点 WHATEVER_YOU_WANT 不存在!”。例如,如果您使用名为 mysite 的文件并尝试使用命令 "a2ensite mysite" 启用配置 mysite,您会收到错误消息。如果您使用一个名为 myfile.conf 的文件,同样的命令也可以正常工作...工作!!
    3. 您可以在sites-available 中创建一个具有正确扩展名(.conf) 的软链接,指向一个已经在sites-available 中没有正确扩展名的文件。在这种情况下,配置将起作用,但如果您使用 a2dissite 禁用该站点,它将显示“错误:站点 WHATEVER_YOU_WANT 不存在!”

    找到解决方案后,我发现了一些链接 https://www.linode.com/docs/security/upgrading/updating-virtual-host-settings-from-apache-2-2-to-apache-2-4

    【讨论】:

      猜你喜欢
      • 2016-08-06
      • 2016-07-17
      • 2014-05-24
      • 2014-11-07
      • 1970-01-01
      • 2013-11-26
      • 1970-01-01
      • 1970-01-01
      • 2015-12-12
      相关资源
      最近更新 更多