Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache httpd上的虚拟主机无意重定向 我的目标_Apache_Httpd.conf - Fatal编程技术网

Apache httpd上的虚拟主机无意重定向 我的目标

Apache httpd上的虚拟主机无意重定向 我的目标,apache,httpd.conf,Apache,Httpd.conf,正在运行具有1个IP的2名虚拟主机。例如,front1.httpd.example.com和front2.httpd.example.com可以在1台服务器的1个httpd(父)进程上访问(我想在front1和front2的端口80上侦听) 环境 HTTPD2.4和Ubuntu 11(32位) 我所做的 根据最新的官方文档,我在httpd.conf上添加了两个虚拟主机 我还更新了我的服务器/etc/hosts和客户机主机,如下所示 服务器的主机(220.xxx.xxx.xxx是一些实际的IP)

正在运行具有1个IP的2名虚拟主机。例如,
front1.httpd.example.com
front2.httpd.example.com
可以在1台服务器的1个httpd(父)进程上访问(我想在front1和front2的端口80上侦听)

环境 HTTPD2.4和Ubuntu 11(32位)

我所做的 根据最新的官方文档,我在httpd.conf上添加了两个虚拟主机

我还更新了我的服务器/etc/hosts和客户机主机,如下所示

服务器的主机(220.xxx.xxx.xxx是一些实际的IP)

客户的主机

220.xxx.xxx.xxx front1.httpd.example.com
220.xxx.xxx.xxx front2.httpd.example.com
此外,我的主机名是
front1.httpd.example.com

(注意:我还尝试在VirtualHost部分之前添加
NameVirtualHost*:80
,但它只是返回附加消息“NameVirtualHost无效…”)

结果 当我访问
front1.httpd.example.com/index.html
时,返回
htdocs/xxxx/index.html
。这是我所期望的,但是当我访问
front2.httpd.example.com/index.html
时,也会返回
htdocs/xxxx/index.html
,尽管我打算显示
htdocs/yyy/index.html
。 (在浏览器控制台消息中,找到
front2.httpd.example.com/index.html
,然后302重定向到
front1.httpd.example.com/index.html

如果没有匹配的结果可访问,虚拟主机将返回第一个虚拟主机值。因此,我还尝试更改虚拟主机的Order,如下所示:

第一次尝试:

<VirtualHost *:80>
    DocumentRoot "/opt/APACHE/httpd/htdocs/xxxx"
    ServerName front1.httpd.example.com
    ServerAlias front1.httpd.example.com
    ErrorLog "logs/dummy-host1.example.com-error_log"

    <Directory "/opt/APACHE/httpd/htdocs/xxxx">
      Options Indexes FollowSymLinks
      AllowOverride all
      Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/opt/APACHE/httpd/htdocs/yyyy"
    ServerName front2.httpd.example.com
    ServerAlias front2.httpd.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    <Directory "/opt/APACHE/httpd/htdocs/yyyy">
      Options Indexes FollowSymLinks
      AllowOverride all
      Require all granted
    </Directory>
</VirtualHost>

我正在这个服务器实例上使用OpenAM Web策略代理

因此,只要将每个FQDN添加到OpenAm代理概要文件上的FQDN虚拟映射中,就可以达到我的目标

<VirtualHost *:80>
    DocumentRoot "/opt/APACHE/httpd/htdocs/xxxx"
    ServerName front1.httpd.example.com
    ServerAlias front1.httpd.example.com
    ErrorLog "logs/dummy-host1.example.com-error_log"

    <Directory "/opt/APACHE/httpd/htdocs/xxxx">
      Options Indexes FollowSymLinks
      AllowOverride all
      Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/opt/APACHE/httpd/htdocs/yyyy"
    ServerName front2.httpd.example.com
    ServerAlias front2.httpd.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    <Directory "/opt/APACHE/httpd/htdocs/yyyy">
      Options Indexes FollowSymLinks
      AllowOverride all
      Require all granted
    </Directory>
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "/opt/APACHE/httpd/htdocs/yyyy"
    ServerName front2.httpd.example.com
    ServerAlias front2.httpd.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    <Directory "/opt/APACHE/httpd/htdocs/yyyy">
      Options Indexes FollowSymLinks
      AllowOverride all
      Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/opt/APACHE/httpd/htdocs/xxxx"
    ServerName front1.httpd.example.com
    ServerAlias front1.httpd.example.com
    ErrorLog "logs/dummy-host1.example.com-error_log"

    <Directory "/opt/APACHE/httpd/htdocs/xxxx">
      Options Indexes FollowSymLinks
      AllowOverride all
      Require all granted
    </Directory>
</VirtualHost>
ServerRoot "/opt/APACHE/httpd"

Listen 80

<VirtualHost *:80>
    DocumentRoot "/opt/APACHE/httpd/htdocs/xxxx"
    ServerName front1.httpd.example.com
    ServerAlias front1.httpd.example.com
    ErrorLog "logs/dummy-host1.example.com-error_log"

    <Directory "/opt/APACHE/httpd/htdocs/xxxx">
      Options Indexes FollowSymLinks
      AllowOverride all
      Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/opt/APACHE/httpd/htdocs/yyyy"
    ServerName front2.httpd.example.com
    ServerAlias front2.httpd.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    <Directory "/opt/APACHE/httpd/htdocs/yyyy">
      Options Indexes FollowSymLinks
      AllowOverride all
      Require all granted
    </Directory>
</VirtualHost>

LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so

<IfModule unixd_module>
User ubuntu
Group ubuntu
</IfModule>

<Directory />
    AllowOverride none
    Require all denied
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" common

</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/opt/APACHE/httpd/cgi-bin/"
</IfModule>

<IfModule cgid_module>
</IfModule>

<Directory "/opt/APACHE/httpd/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig conf/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>