Apache 2.4无法识别其他站点-404错误

如何解决Apache 2.4无法识别其他站点-404错误

背景:我在RHEL 7上运行Apache 2.4.25。现有网站已经存在多年,现在我想添加一个其他不相关的运行Angular的网站。

主要问题:无论我做什么,我都无法将流量路由到新网站。

预期的行为:现有站点在8443上继续运行,新站点在10443上运行。

实际行为:现有站点在8443和10443上侦听,但是新站点在这两者上都返回404。

文件系统位置

  • Apache服务器:/ opt / intapache /
  • 现有(功能性)网站:/ opt / cspgateway /
  • 新的(非功能性)站点:/ opt / intapache / htdocs /(注意:此目录中的index.html设置为755文件访问权限)

当前文件:http.conf指向第二个conf

httpd.conf:

ServerRoot "/opt/intapache/"

Listen 8443

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 socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule socache_dbm_module modules/mod_socache_dbm.so
LoadModule socache_memcache_module modules/mod_socache_memcache.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 ssl_module modules/mod_ssl.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 cachedb
    Group cachedb
</IfModule>

ServerAdmin you@example.com

ServerName example.com

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

DocumentRoot "/opt/cspgateway/csp"
<Directory "/opt/cspgateway/csp">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</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/intapache//cgi-bin/"
</IfModule>

<IfModule cgid_module>
</IfModule>

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

<IfModule headers_module>
    RequestHeader unset Proxy early
</IfModule>

<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>

Include conf/extra/cspgateway.conf 

cspgateway.conf

<VirtualHost *:8443>
    DocumentRoot /opt/cspgateway/csp
    ServerName example.com

    SSLEngine on
    SSLCertificateFile "/opt/example.crt"
    SSLCertificateKeyFile "/opt/example.key"
    SSLCertificateChainFile "/opt/chaincert.crt"

    SSLProtocol All -SSLv2 -SSLv3 +TLSv1.2

</VirtualHost>


Listen 10443
<VirtualHost *:10443>
    DocumentRoot /opt/intapache/htdocs
    ServerName example.com

    SSLEngine on
    SSLCertificateFile "/opt/example.crt"
    SSLCertificateKeyFile "/opt/example.key"
    SSLCertificateChainFile "/opt/chaincert.crt"
    SSLProtocol All -SSLv2 -SSLv3 +TLSv1.2

    <Directory "/opt/intapache/htdocs">
        AllowOverride None
        Options Indexes FollowSymLinks
        Require all granted
    </Directory>
</VirtualHost>

LoadModule csp_module_sa /opt/cspgateway/bin/CSPa24.so
CSPModulePath /opt/cspgateway/bin/

<Location "/csp/bin/Systems/">
    SetHandler cspsys-handler-sa
</Location>
<Location "/csp/bin/RunTime/">
    SetHandler csp-handler-sa
</Location>

<Location />
    CSP On
</Location>

CSPFileTypes csp cls zen cxw gif jpeg jpg jpe png sgi svg svgz tiff tif ico
Alias /csp/ /opt/cspgateway/csp/
<Directory "/opt/cspgateway/csp">
     AllowOverride None
     Options MultiViews FollowSymLinks ExecCGI
     Order allow,deny
     Allow from all
     <FilesMatch "\.(log|ini|pid|exe)$">
         Deny from all
     </FilesMatch>
</Directory>


## START SDS-POC CONFIG ##
<Directory "/opt/intapache/htdocs">
    AllowOverride None
    Options MultiViews FollowSymLinks ExecCGI
    Require all granted
</Directory>
## END SDS-POC CONFIG ##


SSLSessionCache "shmcb:logs/ssl_scache(512000)"

解决方法

在提供有限信息的情况下,我构建了此配置。

httpd.conf

ServerRoot "/opt/intapache/"

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 socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule socache_dbm_module modules/mod_socache_dbm.so
LoadModule socache_memcache_module modules/mod_socache_memcache.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 ssl_module modules/mod_ssl.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 cachedb
    Group cachedb
</IfModule>

ServerAdmin you@example.com

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

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


<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>
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/opt/intapache//cgi-bin/"
</IfModule>

<IfModule cgid_module>
</IfModule>

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

<IfModule headers_module>
    RequestHeader unset Proxy early
</IfModule>

<IfModule mime_module>
    TypesConfig conf/mime.types

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

<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin

    SSLSessionCache "shmcb:logs/ssl_scache(512000)"
</IfModule>

Include conf/extra/cspgateway.conf 

conf / extra / cspgateway.conf

Listen 8443
<VirtualHost *:8443>
    ServerName OLD-example.com

    CustomLog "logs/8443_access_log" combined
    ErrorLog "logs/8443_error_log"
    LogLeval debug

    SSLEngine on
    SSLCertificateFile "/opt/OLD-example.crt"
    SSLCertificateKeyFile "/opt/OLD-example.key"
    SSLCertificateChainFile "/opt/OLD-chaincert.crt"

    SSLProtocol All -SSLv2 -SSLv3 +TLSv1.2
  
    DirectoryIndex index.html

    LoadModule csp_module_sa /opt/cspgateway/bin/CSPa24.so
    CSPModulePath /opt/cspgateway/bin/

    <Location />
        CSP On
    </Location>
    <Location "/csp/bin/Systems/">
        SetHandler cspsys-handler-sa
    </Location>
    <Location "/csp/bin/RunTime/">
        SetHandler csp-handler-sa
    </Location>

    CSPFileTypes csp cls zen cxw gif jpeg jpg jpe png sgi svg svgz tiff tif ico
    DocumentRoot "/opt/cspgateway/csp"
    Alias /csp/ /opt/cspgateway/csp/
    <Directory "/opt/cspgateway/csp">
         AllowOverride None
         Options MultiViews FollowSymLinks ExecCGI
         Order allow,deny
         Allow from all
         <FilesMatch "\.(log|ini|pid|exe)$">
             Deny from all
         </FilesMatch>
    </Directory>

</VirtualHost>

Listen 10443
<VirtualHost *:10443>
    ServerName NEW-example.com

    CustomLog "logs/10443_access_log" combined
    ErrorLog "logs/10443_error_log"
    LogLeval debug

    SSLEngine on
    SSLCertificateFile "/opt/NEW-example.crt"
    SSLCertificateKeyFile "/opt/NEW-example.key"
    SSLCertificateChainFile "/opt/NEW-chaincert.crt"
    SSLProtocol All -SSLv2 -SSLv3 +TLSv1.2

    DocumentRoot /opt/intapache/htdocs
    <Directory "/opt/intapache/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    DirectoryIndex index.html
</VirtualHost>

已完成

  • 将两个站点分开,每个站点都放在单独的VirtualHost中。
  • 拆分日志文件,每个VirtualHost一个。这有助于调试每个站点的状况。我现在还设置了LogLevel debug,一旦可以正常工作,就应该将其设置为不那么冗长。
  • 为SSL设置不同的证书。如果您确实希望两个站点都具有相同的域名,则可以撤消此操作。因为您使用了不同的端口,所以这里是可能的。
  • 与每个站点相关的所有配置都包含在其正确的VirtualHost中。例如目录或CSP模块。我有一种直觉,因为这个模块是在之前的通用部​​分中加载的,所以它在8844和10443的两个连接上都被激活。据我所知,它应该仅在8844的连接上才是活动的,我在这里做了。
  • 只有8443具有选项Options MultiViews FollowSymLinks ExecCGI。对于10443,它使用“常规”选项来提供html页面及其资源。
  • SSLSessionCache已移至httpd.conf,因为这是一个通用指令。
  • 我删除了以下伪指令:Include conf/extra/proxy-html.conf。没有加载的模块,没有指令。

以这种方式进行操作可确保每个站点彼此独立。尽管我不知道CSP的作用,但我猜想它在两个站点上都不应该处于活动状态,因此将其移至8443 VirtualHost中。

最后一点,应在服务器上打开端口8443和10443,以允许客户端连接到它们。


如果这不起作用,请提出一个新问题,并包括:

  • 配置文件
  • 日志条目
  • 预期行为
  • 当前行为
  • 尽可能多的细节!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-